src/Controller/EditionController.php line 844

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Edition;
  4. use App\Entity\Feedback;
  5. use App\Entity\Zayavka;
  6. use App\Entity\ZayavkaMono;
  7. use App\Form\EditionType;
  8. use App\Form\RussianPostType;
  9. use App\Message\EditionSendEmailPdfMessage;
  10. use App\Service\Edition\EditionAddGoogleTab;
  11. use App\Service\EditionDate;
  12. use App\Service\EditionFunction;
  13. use App\Service\FileUploader;
  14. use App\Service\MetaTags\MetaTags;
  15. use App\Service\Path\Classes\PathEntity;
  16. use App\Service\PdfGeneration\PdfGeneration;
  17. use App\Service\Price;
  18. use App\Service\RussianPost\RussianPostFunction;
  19. use Doctrine\ORM\EntityManagerInterface;
  20. use Knp\Component\Pager\PaginatorInterface;
  21. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  22. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  23. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  24. use Symfony\Component\Form\Extension\Core\Type\TextType;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\HttpFoundation\Response;
  27. use Symfony\Component\Messenger\MessageBusInterface;
  28. use Symfony\Component\Routing\Annotation\Route;
  29. class EditionController extends AbstractController
  30. {
  31.     private $editionDate;
  32.     private $editionFunction;
  33.     private $pdfGeneration;
  34.     private $pathEntity;
  35.     private $metaTags;
  36.     private $em;
  37.     private $bus;
  38.     public function __construct(EditionDate $editionDateEditionFunction $editionFunctionPdfGeneration $pdfGenerationPathEntity $pathEntityMetaTags $metaTagsEntityManagerInterface $emMessageBusInterface $bus)
  39.     {
  40.         $this->editionDate $editionDate;
  41.         $this->editionFunction $editionFunction;
  42.         $this->pdfGeneration $pdfGeneration;
  43.         $this->pathEntity $pathEntity;
  44.         $this->metaTags $metaTags;
  45.         $this->em $em;
  46.         $this->bus $bus;
  47.     }
  48.     /**
  49.      * @Route("/admin/edition/ajax/get/{name}", name="edition_ajax_get", methods={"GET"})
  50.      */
  51.     public function edition_ajax_get($name)
  52.     {
  53.         $editions = [];
  54.         $result $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  55.             ->select('e.id, e.name, e.date_end')
  56.             ->andWhere('e.name LIKE :name')
  57.             ->setParameter('name''%' $name '%')
  58.             ->orderBy('e.name''ASC')
  59.             ->getQuery()
  60.             ->getArrayResult();
  61.         if ($result) {
  62.             foreach ($result as $item) {
  63.                 $editions[] = ['name' => $item['name'] . ' (' $item['date_end']->format('d.m.Y') . ') [' $item['id'] . ']'];
  64.             }
  65.         }
  66.         return $this->json($editions $editions FALSE);
  67.     }
  68.     /**
  69.      * @Route("/admin/edition", priority=11, name="edition_index", methods={"GET"})
  70.      */
  71.     public function index(Request $requestPaginatorInterface $paginator): Response
  72.     {
  73.         $Editions $this->em->getRepository(Edition::class)->createQueryBuilder('e')->orderBy('e.id''DESC');
  74.         $direction = [];
  75.         foreach ($this->getParameter('direction') as $key => $item) {
  76.             if (!empty($item['label'])) $direction[$item['label']] = $key;
  77.         }
  78.         $form $this->createFormBuilder(['name' => ''], ['csrf_protection' => false])
  79.             ->add('name'TextType::class, [
  80.                 'required' => false,
  81.                 'label' => 'Название конференции',
  82.             ])
  83.             ->add('direction'ChoiceType::class, [
  84.                 'required' => false,
  85.                 'label' => 'Конференция',
  86.                 'choices' => $direction,
  87.             ])
  88.             ->add('active'ChoiceType::class, [
  89.                 'required' => false,
  90.                 'label' => 'Текущие выпуски',
  91.                 'choices' => ['Да' => 1'Нет' => 0],
  92.                 'placeholder' => 'Все'
  93.             ])
  94.             ->setMethod('GET')
  95.             ->getForm();
  96.         if ($request->getMethod() == 'GET') {
  97.             $form->handleRequest($request);
  98.             $data $form->getData();
  99.         }
  100.         if (isset($data['active'])) {
  101.             if($data['active'] == 0) {
  102.                 $Editions->andWhere('e.date_end <= :time')->setParameter('time'date("Y-m-d 00:00:00"time()));
  103.             } elseif ($data['active'] == 1){
  104.                 $Editions->andWhere('e.date_end >= :time')->setParameter('time'date("Y-m-d 00:00:00"time()));
  105.             }
  106.         }
  107.         if (!empty($data['name'])) {
  108.             $Editions->andWhere('e.name LIKE :title')
  109.                 ->setParameter('title''%' $data['name'] . '%');
  110.         }
  111.         if (!empty($data['direction'])) {
  112.             $Editions->andWhere('e.direction = :direction')
  113.                 ->setParameter('direction'$data['direction']);
  114.         }
  115.         $pagination $paginator->paginate(
  116.             $Editions->getQuery(), $request->query->getInt('page'1), 30);
  117.         $pagination->setTemplate('@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig');
  118.         return $this->render('admin/edition/index.html.twig', [
  119.             'editions' => $pagination,
  120.             'form' => $form->createView(),
  121.         ]);
  122.     }
  123.     /**
  124.      * @Route("/admin/edition/{id}/price_update", priority=11, name="edition_price_update", methods={"GET","POST"}, requirements={"path"="\d+"})
  125.      */
  126.     public function price_update(Edition $editionRequest $requestPrice $price): Response
  127.     {
  128.         $edition->setPrice(serialize($price->getActualPrice($this->editionFunction->getEditionType($edition->getDirection()))));
  129.         $this->em->persist($edition);
  130.         $this->em->flush();
  131.         return $this->render('admin/edition/price_update.html.twig', [
  132.             'edition' => $edition
  133.         ]);
  134.     }
  135.     /**
  136.      * @Route("/admin/edition/price_update/all", priority=11, name="edition_all_price_update", methods={"GET","POST"})
  137.      */
  138.     public function all_price_update(Price $price): Response
  139.     {
  140.         $editions $this->em->getRepository(Edition::class)->findAll();
  141.         foreach ($editions as $edition) {
  142.             $edition->setPrice(serialize($price->getActualPrice($this->editionFunction->getEditionType($edition->getDirection()))));
  143.             $this->em->persist($edition);
  144.             $this->em->flush();
  145.         }
  146.         return $this->render('admin/edition/all_price_update.html.twig', []);
  147.     }
  148.     /**
  149.      * @Route("/admin/edition/price_update/actual", priority=11, name="edition_actual_price_update", methods={"GET"})
  150.      */
  151.     public function actual_price_update(Price $price): Response
  152.     {
  153.         $editions $this->em->getRepository(Edition::class)->getActualEditions();
  154.         foreach ($editions as $edition) {
  155.             $edition->setPrice(serialize($price->getActualPrice($this->editionFunction->getEditionType($edition->getDirection()))));
  156.             $this->em->persist($edition);
  157.             $this->em->flush();
  158.         }
  159.         return $this->render('admin/edition/all_price_update.html.twig', []);
  160.     }
  161.     /**
  162.      * @Route("/admin/edition/{id}/article_parts", priority=11, name="edition_article_parts", methods={"GET","POST"}, requirements={"path"="\d+"})
  163.      */
  164.     public function article_parts(Edition $editionRequest $request): Response
  165.     {
  166.         if (!empty($edition->getEditionPages()[1])) {
  167.             if ($edition->getDirection() == 'mono') {
  168.                 $zayavka $this->em->getRepository(ZayavkaMono::class)->createQueryBuilder('z')
  169.                     ->join('z.article''article')
  170.                     ->join('z.edition''edition')
  171.                     ->andWhere('edition.id = :id')
  172.                     ->setParameter('id'$edition->getId())
  173.                     ->andWhere('z.print_journal > 0')
  174.                     ->andWhere('article.id IS NOT NULL AND (article.part IS NULL OR article.part = 0)')
  175.                     ->orderBy('z.id''DESC')
  176.                     ->getQuery()
  177.                     ->getResult();
  178.             } else {
  179.                 $zayavka $this->em->getRepository(Zayavka::class)->createQueryBuilder('z')
  180.                     ->join('z.article''article')
  181.                     ->join('z.edition''edition')
  182.                     ->andWhere('edition.id = :id')
  183.                     ->setParameter('id'$edition->getId())
  184.                     ->andWhere('z.print_journal > 0')
  185.                     ->andWhere('article.id IS NOT NULL AND (article.part IS NULL OR article.part = 0)')
  186.                     ->orderBy('z.id''DESC')
  187.                     ->getQuery()
  188.                     ->getResult();
  189.             }
  190.             return $this->render('admin/edition/article_parts.html.twig', [
  191.                 'zayavkas' => $zayavka,
  192.                 'edition' => $edition,
  193.             ]);
  194.         }
  195.         die('Данные заполнены');
  196.     }
  197.     /**
  198.      * @Route("/admin/edition/updategoogle", priority=11, name="edition_updateGoogle", methods={"GET","POST"})
  199.      */
  200.     public function updateGoogle(EditionAddGoogleTab $editionAddGoogleTab): Response
  201.     {
  202.         return $this->render('admin/edition/updateGoogle.html.twig', [
  203.             'result' => $editionAddGoogleTab->addEdition()
  204.         ]);
  205.     }
  206.     /**
  207.      * @Route("/admin/edition/new", priority=11, name="edition_new", methods={"GET","POST"})
  208.      */
  209.     public function new(Request $requestFileUploader $fileUploaderEditionFunction $editionFunction): Response
  210.     {
  211.         $edition = new Edition();
  212.         $edition->setUser($this->getUser());
  213.         $form $this->createForm(EditionType::class, $edition);
  214.         $form->handleRequest($request);
  215.         if ($form->isSubmitted() && $form->isValid()) {
  216.             $edition->setCreated(time());
  217.             $edition->setUpdated(time());
  218.             $edition->setEmailSubscribe(FALSE);
  219.             $Cover $form->get('cover')->getData();
  220.             if ($Cover) {
  221.                 $CoverFileName $fileUploader->upload($Cover'edition/cover/' $editionFunction->getEditionType($edition->getDirection()));
  222.                 $edition->setCover($CoverFileName);
  223.             }
  224.             $edition->setFile('edition/pdf/' str_replace('/''-'$edition->getDirection()) . '-' $edition->getNumber() . '.pdf');
  225.             $this->em->persist($edition);
  226.             $this->em->flush();
  227.             $this->pathEntity->setPath($edition);
  228.             $this->pdfGeneration->createPdfEdition($edition);
  229.             return $this->redirectToRoute('edition_index');
  230.         }
  231.         return $this->render('admin/edition/new.html.twig', [
  232.             'edition' => $edition,
  233.             'form' => $form->createView(),
  234.         ]);
  235.     }
  236.     /**
  237.      * @Route("/admin/edition/{id}/edit", priority=11, name="edition_edit", methods={"GET","POST"})
  238.      */
  239.     public function edit(Request $requestEdition $editionFileUploader $fileUploaderEditionFunction $editionFunction): Response
  240.     {
  241.         $form $this->createForm(EditionType::class, $edition);
  242.         $form->handleRequest($request);
  243.         if ($form->isSubmitted() && $form->isValid()) {
  244.             $edition->setUpdated(time());
  245.             $Cover $form->get('cover')->getData();
  246.             if ($Cover) {
  247.                 $CoverFileName $fileUploader->upload($Cover'edition/cover/' $editionFunction->getEditionType($edition->getDirection()));
  248.                 if ($edition->getCover()) $fileUploader->delete($edition->getCover());
  249.                 $edition->setCover($CoverFileName);
  250.             }
  251.             if($edition->getDirection() !== 'authorsmono'$this->pdfGeneration->createPdfEdition($edition);
  252.             if(!$edition->isSendEmailPdf()) {
  253.                 if(!empty($edition->getEditionPages()[0]) && !empty($edition->getEditionPages()[0]->getFilepath()) && $edition->getDatePubl()->getTimestamp() > (time() - 86400 3)) {
  254.                     $edition->setSendEmailPdf(1);
  255.                     $this->bus->dispatch(new EditionSendEmailPdfMessage(['id' => $edition->getId()]));
  256.                 }
  257.             }
  258.             $this->em->flush();
  259.             return $this->redirectToRoute('edition_index');
  260.         }
  261.         return $this->render('admin/edition/edit.html.twig', [
  262.             'edition' => $edition,
  263.             'form' => $form->createView(),
  264.         ]);
  265.     }
  266.     /**
  267.      * @Route("/admin/edition/{id}", priority=11, name="edition_delete", methods={"DELETE"})
  268.      */
  269.     public function delete(Request $requestEdition $edition): Response
  270.     {
  271.         if ($this->isCsrfTokenValid('delete' $edition->getId(), $request->request->get('_token'))) {
  272.             $this->em->remove($edition);
  273.             $this->em->flush();
  274.         }
  275.         return $this->redirectToRoute('edition_index');
  276.     }
  277.     /**
  278.      * @Route("/admin/edition/{id}/pdf/update", priority=11, name="admin_pdf_update", methods={"GET"})
  279.      */
  280.     public function admin_pdf_update(Edition $edition): Response
  281.     {
  282.         $this->pdfGeneration->createPdfEdition($edition);
  283.         echo '<a href="/' $edition->getFile() . '">Ссылка на PDF</a>';
  284.         die();
  285.         return $this->redirect('/' $edition->getFile());
  286.     }
  287.     /**
  288.      * @Route("/admin/edition/{id}/report_cert", priority=11, name="admin_edition_report", methods={"GET","POST"})
  289.      */
  290.     public function admin_report(Edition $edition)
  291.     {
  292.         if ($edition) {
  293.             $filepath $this->editionFunction->getReport($edition);
  294.             if (file_exists($filepath)) {
  295.                 $path_info pathinfo($filepath);
  296.                 $filename $path_info['basename'];
  297.                 header('Content-Type: application/x-force-download; name="' $filename '"');
  298.                 header("Content-Disposition: attachment; filename=$filename");
  299.                 readfile($filepath);
  300.             } else {
  301.                 header("HTTP/1.1 404 Not Found");
  302.                 echo '404 Not Found';
  303.             }
  304.         }
  305.         die();
  306.     }
  307.     /**
  308.      * @Route("/admin/edition/{id}/postmail", priority=11, name="admin_edition_postmail", methods={"GET","POST"})
  309.      */
  310.     public function admin_postmail(Edition $editionRequest $requestRussianPostFunction $russianPostFunction): Response
  311.     {
  312.         //Создаем форму для создания трек номеров в Почте России
  313.         $form $this->createFormBuilder(['name' => ''], ['csrf_protection' => false])
  314.             ->add('send'SubmitType::class, ['label' => 'Создать Рассылку'])
  315.             ->getForm();
  316.         if ($request->getMethod() == 'POST') {
  317.             $form->handleRequest($request);
  318.         }
  319.         $batch '<div class="new">Новые пакеты отправления дата сдачи: <span>' date('Y-m-d'strtotime('next thursday')) . '</span></div>';
  320.         $batchId = [];
  321.         if ($PostMailBatch $russianPostFunction->getBatch()) {
  322.             $batch '<p><strong>Существующие пакеты отправлений:</strong></p><ul>';
  323.             foreach ($PostMailBatch as $key => $item) {
  324.                 $batch .= '<li data-id="' $item['batch-name'] . '" data-batch_name="' $key '"><strong>' $key '</strong> Номер пакета: ' $item['batch-name'] . ' Дата сдачи в ОПС ' $item['list-number-date'] . '</li>';
  325.                 $batchId[] = $item['batch-name'];
  326.             }
  327.             $batch .= '</ul>';
  328.         }
  329.         $send_text '';
  330.         if ($form->getClickedButton() && 'send' === $form->getClickedButton()->getName()) {
  331.             // Нажата кнопка send
  332.             $send_text $russianPostFunction->creatPost($edition$batchId);
  333.         } else {
  334.             foreach ($edition->getEditionPages() as $key => $item) {
  335.                 $form->add('weight_journal_' . ($key 1), TextType::class, [
  336.                     'attr' => [
  337.                         'class' => 'weight_journal',
  338.                         'data-id' => ($key 1)
  339.                     ],
  340.                     'required' => false,
  341.                     'label' => 'Вес сборника/журнала/монографии №' . ($key 1),
  342.                 ]);
  343.             }
  344.         }
  345.         if($russianPosts $russianPostFunction->getFormsEditionRussianPost($edition)) {
  346.             //массив с формами отправлений
  347.             $PostMailForms = [];
  348.             foreach ($russianPosts as $russianPost) {
  349.                 $PostMailForms[] = $this->createForm(RussianPostType::class, $russianPost, [
  350.                     'action' => empty($russianPost->getId()) ? $this->generateUrl('russianpost_new') : $this->generateUrl('russianpost_update', ['id' => $russianPost->getId()]),
  351.                     'method' => 'POST',
  352.                 ])->createView();
  353.             }
  354.         }
  355.         return $this->render('admin/edition/postmail.html.twig', [
  356.             'PostMailForms' => $PostMailForms,
  357.             'form' => $form->createView(),
  358.             'batch' => $batch,
  359.             'send_text' => $send_text,
  360.         ]);
  361.     }
  362.     /**
  363.      * @Route("/admin/edition/{id}", priority=11, name="admin_edition_show", methods={"GET"}, requirements={"path"="\d+"})
  364.      */
  365.     public function admin_show(Edition $edition): Response
  366.     {
  367.         return $this->render('admin/edition/show.html.twig', [
  368.             'edition' => $edition,
  369.         ]);
  370.     }
  371.     /**
  372.      * @Route("/stud-herald-jsonu3vb4jx", priority=11, name="edition_stud_herald_export", methods={"GET"})
  373.      */
  374.     public function edition_stud_herald_export(): Response
  375.     {
  376.         $output = [];
  377.         $Editions $this->em->getRepository(Edition::class)->getStudmagazine('studmagazine');
  378.         foreach ($Editions as $edition) {
  379.             $output[$edition->getId()] = array(
  380.                 'number' => $edition->getNumber(),
  381.                 'cover' => 'https://www.internauka.org/' $edition->getCover(),
  382.                 'elibrary' => $edition->getLinkElibrary(),
  383.                 'pdf' => [],
  384.                 'pages' => [],
  385.                 'date_end' => $edition->getDateEnd()->format('c'),
  386.                 'data_publ' => $edition->getDatePubl()->format('c'),
  387.             );
  388.         }
  389.         if (!empty($edition->getEditionPages())) {
  390.             foreach ($edition->getEditionPages() as $editionPage) {
  391.                 if (!empty($editionPage->getFilepath())) $output[$edition->getId()]['pdf'][] = $editionPage->getFilepath();
  392.                 if (!empty($editionPage->getPages())) $output[$edition->getId()]['pages'][] = $editionPage->getPages();
  393.             }
  394.         }
  395.         return $this->json($output);
  396.     }
  397.     /**
  398.      * @Route("/archive", name="edition_archive", methods={"GET"})
  399.      */
  400.     public function edition_archive(Request $requestPaginatorInterface $paginator)
  401.     {
  402.         $defaultData = array('title' => '');
  403.         $years = ['За все время' => 'all'] + array_combine(range(2012date('Y')), range(2012date('Y')));
  404.         $form $this->createFormBuilder($defaultData, ['csrf_protection' => false])
  405.             ->add('edition'ChoiceType::class, [
  406.                 'choices' => ['Все издания' => 'all''Журнал' => 'journal''Книга' => 'authorsmono''Конференция' => 'conf''Монография' => 'mono'],
  407.                 'required' => true,
  408.                 'label' => 'Тип издания',
  409.             ])
  410.             ->add('year'ChoiceType::class, [
  411.                 'choices' => $years,
  412.                 'required' => true,
  413.                 'label' => 'Год издания',
  414.             ])
  415.             ->add('articles'TextType::class, [
  416.                 'required' => false,
  417.                 'label' => 'Название статьи/главы',
  418.             ])
  419.             ->add('authors'TextType::class, [
  420.                 'required' => false,
  421.                 'label' => 'ФИО автора',
  422.             ])
  423.             ->setMethod('GET')
  424.             ->getForm();
  425.         $data = [];
  426.         if ($request->getMethod() == 'GET') {
  427.             $form->handleRequest($request);
  428.             $data $form->getData();
  429.         }
  430.         $editions $this->em->getRepository(Edition::class)->getArchive($data);
  431.         $pagination $paginator->paginate(
  432.             $editions$request->query->getInt('page'1), 30);
  433.         if (!empty($data['articles'])) {
  434.             foreach ($pagination as $edition) {
  435.                 foreach ($edition->getArticles() as $article) {
  436.                     $title preg_replace("/(" $data['articles'] . ")/ius""<span>\\1</span>"$article->getTitle());
  437.                     $article->setTitle($title);
  438.                     if (!empty($data['authors'])) {
  439.                         foreach ($article->getArticleAuthors() as $articleAuthor) {
  440.                             $name preg_replace("/(" $data['authors'] . ")/ius""<span>\\1</span>"$articleAuthor->getAuthors()->getName());
  441.                             $articleAuthor->getAuthors()->setName($name);
  442.                         }
  443.                         foreach ($article->getArticleScidirectors() as $articleAuthor) {
  444.                             $name preg_replace("/(" $data['authors'] . ")/ius""<span>\\1</span>"$articleAuthor->getAuthors()->getName());
  445.                             $articleAuthor->getAuthors()->setName($name);
  446.                         }
  447.                     }
  448.                 }
  449.             }
  450.         }
  451.         return $this->render('edition/archive.html.twig', [
  452.             'editions' => $pagination,
  453.             'form' => $form->createView(),
  454.             'metaTags' => $this->metaTags->getEditionArchive(),
  455.         ]);
  456.     }
  457.     /**
  458.      * Убираем что бы небыло дублей@Route("/edition/{id}", name="edition_show", methods={"GET"})
  459.      */
  460.     public function show($id): Response
  461.     {
  462.         $edition $this->em->getRepository(Edition::class)->find($id);
  463.         if ($edition->getStatus()) {
  464.             $type '';
  465.             if(!empty($_GET['type']) && in_array($_GET['type'], ['articles''public'])) $type $_GET['type'];
  466.             $this->metaTags->setEdition($edition);
  467.             $InfoEdition $this->editionFunction->getInfoEdition($edition);
  468.             $direction 0;
  469.             if($InfoEdition['type'] == 'studJournal'){
  470.                 $direction 1;
  471.             } elseif($InfoEdition['type'] == 'journal'){
  472.                 $direction 2;
  473.             } elseif($InfoEdition['type'] == 'studConf'){
  474.                 $direction 3;
  475.             } elseif($InfoEdition['type'] == 'nauchConf' || $InfoEdition['type'] == 'worldConf'){
  476.                 $direction 4;
  477.             } elseif($InfoEdition['type'] == 'mono'){
  478.                 $direction 7;
  479.             }
  480.             $feedbacks $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
  481.                 ->andWhere('f.status = 1')
  482.                 ->andWhere('f.direction = :direction')
  483.                 ->setParameter('direction'$direction)
  484.                 ->orderBy('f.id''DESC')
  485.                 ->setMaxResults(10)
  486.                 ->getQuery()
  487.                 ->getResult();
  488.             $template 'edition/show.html.twig';
  489.             if ($InfoEdition['type'] == 'worldConf'$template 'edition/full_show.html.twig';
  490.             return $this->render($template, [
  491.                 'editionInfo' => $InfoEdition,
  492.                 'type' => $type,
  493.                 'feedbacks' => $feedbacks,
  494.             ]);
  495.         }
  496.         throw $this->createNotFoundException('404');
  497.     }
  498.     /**
  499.      * @Route("/conf/{path}", name="edition_show_conf", methods={"GET","POST"})
  500.      */
  501.     public function show_conf($path)
  502.     {
  503.         $directionParameter $this->getParameter('direction');
  504.         foreach ($directionParameter as $key => $item) {
  505.             if (!empty($item['path_page'])) {
  506.                 if ($item['path_page'] == 'conf/' $path) {
  507.                     $direction $key;
  508.                     break;
  509.                 }
  510.             }
  511.         }
  512.         if (!empty($direction)) {
  513.             $edition $this->em->getRepository(Edition::class)->getActualEdition($direction);
  514.             $type '';
  515.             if(!empty($_GET['type']) && in_array($_GET['type'], ['articles''public'])) $type $_GET['type'];
  516.             $this->metaTags->setEditionInfo($edition);
  517.             $InfoEdition $this->editionFunction->getInfoEdition($edition);
  518.             $direction 0;
  519.             if($InfoEdition['type'] == 'studJournal'){
  520.                 $direction 1;
  521.             } elseif($InfoEdition['type'] == 'journal'){
  522.                 $direction 2;
  523.             } elseif($InfoEdition['type'] == 'studConf'){
  524.                 $direction 3;
  525.             } elseif($InfoEdition['type'] == 'nauchConf' || $InfoEdition['type'] == 'worldConf'){
  526.                 $direction 4;
  527.             } elseif($InfoEdition['type'] == 'mono'){
  528.                 $direction 7;
  529.             }
  530.             $feedbacks $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
  531.                 ->andWhere('f.status = 1')
  532.                 ->andWhere('f.direction = :direction')
  533.                 ->setParameter('direction'$direction)
  534.                 ->orderBy('f.id''DESC')
  535.                 ->setMaxResults(10)
  536.                 ->getQuery()
  537.                 ->getResult();
  538.             $template 'edition/show.html.twig';
  539.             if ($InfoEdition['type'] == 'worldConf'$template 'edition/full_show.html.twig';
  540.             return $this->render($template, [
  541.                 'editionInfo' => $InfoEdition,
  542.                 'editionInfoFull' => true,
  543.                 'type' => $type,
  544.                 'feedbacks' => $feedbacks,
  545.             ]);
  546.         }
  547.         throw $this->createNotFoundException('404');
  548.     }
  549.     /**
  550.      * @Route("/conference", name="edition_conference_lenta", methods={"GET","POST"})
  551.      */
  552.     public function conference_lenta(Request $requestPaginatorInterface $paginator)
  553.     {
  554.         $direction = ['spain''netherlands''usaconference'];
  555.         $directionParameter $this->getParameter('direction');
  556.         foreach ($directionParameter as $key => $item) {
  557.             if (strpos($key'conf') === 0) {
  558.                 $direction[] = $key;
  559.             }
  560.         }
  561.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  562.             ->andWhere('e.direction IN (:direction)')
  563.             ->andWhere('e.date_end >= :date_end')
  564.             ->andWhere('e.status = 1')
  565.             ->setParameters([':direction' => $direction'date_end' => date('Y-m-d'time())])
  566.             ->orderBy('e.date_end''ASC')
  567.             ->getQuery();
  568.         $EditionsTmp $query->getResult();
  569.         $Editions = [];
  570.         foreach ($EditionsTmp as $key => $item) {
  571.             if (empty($Editions[$item->getDirection()])) $Editions[$item->getDirection()] = $this->editionFunction->getInfoEditionTeaser($item);
  572.         }
  573.         return $this->render('edition/conference.html.twig', [
  574.             'editions' => $Editions,
  575.             'metaTags' => $this->metaTags->getEditionConference(),
  576.             'controller_name' => 'edition_conference_lenta'
  577.         ]);
  578.     }
  579.     /**
  580.      * @Route("/conference/{path}", name="edition_conference_science", methods={"GET","POST"})
  581.      */
  582.     public function conference_science($pathRequest $requestPaginatorInterface $paginator)
  583.     {
  584.         $path_arr = [
  585.             'arhitektura' => ['conf/tech''spain''netherlands''usaconference''conf/inno'],
  586.             'astronomiya' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  587.             'biologiya' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  588.             'veterinarnye-nauki' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  589.             'geografiya' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  590.             'geologiya' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  591.             'informacionnye-tehnologii' => ['conf/math''conf/tech''spain''netherlands''usaconference''conf/inno'],
  592.             'iskusstvovedenie' => ['conf/philology''spain''netherlands''usaconference''conf/inno'],
  593.             'istoriya' => ['conf/social''spain''netherlands''usaconference''conf/inno'],
  594.             'kulturologiya' => ['conf/philology''spain''netherlands''usaconference''conf/inno'],
  595.             'matematika' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  596.             'medicina' => ['conf/med''spain''netherlands''usaconference''conf/inno'],
  597.             'menedzhment' => ['conf/economy''spain''netherlands''usaconference''conf/inno'],
  598.             'pedagogika' => ['conf/pedagogy''spain''netherlands''usaconference''conf/inno'],
  599.             'politologiya' => ['conf/social''spain''netherlands''usaconference''conf/inno'],
  600.             'psihologiya' => ['conf/pedagogy''spain''netherlands''usaconference''conf/inno'],
  601.             'selskohozyaystvennye-nauki' => ['spain''netherlands''usaconference''conf/inno'],
  602.             'sociologiya' => ['conf/social''spain''netherlands''usaconference''conf/inno'],
  603.             'tehnicheskie-nauki' => ['conf/tech''spain''netherlands''usaconference''conf/inno'],
  604.             'farmacevticheskie-nauki' => ['conf/med''spain''netherlands''usaconference''conf/inno'],
  605.             'fizika' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  606.             'filologiya' => ['conf/philology''spain''netherlands''usaconference''conf/inno'],
  607.             'filosofiya' => ['conf/social''spain''netherlands''usaconference''conf/inno'],
  608.             'himiya' => ['conf/math''spain''netherlands''usaconference''conf/inno'],
  609.             'ekonomika' => ['conf/economy''spain''netherlands''usaconference''conf/inno'],
  610.             'yurisprudenciya' => ['conf/law''spain''netherlands''usaconference''conf/inno'],
  611.         ];
  612.         if (!empty($path_arr[$path])) {
  613.             $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  614.                 ->andWhere('e.direction IN (:direction)')
  615.                 ->andWhere('e.date_end >= :date_end')
  616.                 ->andWhere('e.status = 1')
  617.                 ->setParameters([':direction' => $path_arr[$path], 'date_end' => date('Y-m-d'time())])
  618.                 ->orderBy('e.date_end''ASC')
  619.                 ->getQuery();
  620.             $Editions $query->getResult();
  621.             foreach ($Editions as $key => $item) {
  622.                 $this->editionFunction->getInfoEditionTeaser($item);
  623.             }
  624.             $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  625.                 ->andWhere('e.direction IN (:direction)')
  626.                 ->andWhere('e.date_end < :date_end')
  627.                 ->andWhere('e.status = 1')
  628.                 ->setParameters([':direction' => $path_arr[$path], 'date_end' => date('Y-m-d'time())])
  629.                 ->orderBy('e.date_end''DESC')
  630.                 ->getQuery();
  631.             $pagination $paginator->paginate(
  632.                 $query$request->query->getInt('page'1), 30);
  633.             foreach ($pagination->getItems() as $item){
  634.                 $this->editionFunction->getInfoEditionTeaser($item);
  635.             }
  636.             return $this->render('edition/lenta.html.twig', [
  637.                 'editions' => $Editions,
  638.                 'editionsPrev' => $pagination,
  639.                 'metaTags' => $this->metaTags->getEditionConferenceScience($path),
  640.                 'controller_name' => 'edition_conference_science'
  641.             ]);
  642.         }
  643.         throw $this->createNotFoundException('404');
  644.     }
  645.     /**
  646.      * @Route("/journal/science/internauka", name="edition_show_nauch_journal", methods={"GET","POST"})
  647.      */
  648.     public function show_nauch_journal()
  649.     {
  650.         $edition $this->em->getRepository(Edition::class)->getActualEdition('journal');
  651.         $type '';
  652.         if(!empty($_GET['type']) && in_array($_GET['type'], ['articles''public'])) $type $_GET['type'];
  653.         $this->metaTags->setEditionInfo($edition);
  654.         $InfoEdition $this->editionFunction->getInfoEdition($edition);
  655.         $feedbacks $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
  656.             ->andWhere('f.status = 1')
  657.             ->andWhere('f.direction = :direction')
  658.             ->setParameter('direction'2)
  659.             ->orderBy('f.id''DESC')
  660.             ->setMaxResults(10)
  661.             ->getQuery()
  662.             ->getResult();
  663.         return $this->render('edition/show.html.twig', [
  664.             'editionInfo' => $InfoEdition,
  665.             'editionInfoFull' => true,
  666.             'type' => $type,
  667.             'feedbacks' => $feedbacks,
  668.         ]);
  669.     }
  670.     /**
  671.      * @Route("/journal/science", name="edition_nauch_journal_lenta", methods={"GET","POST"})
  672.      */
  673.     public function nauch_journal_lenta(Request $requestPaginatorInterface $paginator)
  674.     {
  675.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  676.             ->andWhere('e.direction = :direction')
  677.             ->andWhere('e.date_end >= :date_end')
  678.             ->andWhere('e.status = 1')
  679.             ->setParameters([':direction' => 'journal''date_end' => date('Y-m-d'time())])
  680.             ->orderBy('e.date_end''ASC')
  681.             ->getQuery();
  682.         $Editions $query->getResult();
  683.         foreach ($Editions as $key => $item) {
  684.             $this->editionFunction->getInfoEditionTeaser($item);
  685.         }
  686.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  687.             ->andWhere('e.direction = :direction')
  688.             ->andWhere('e.date_end < :date_end')
  689.             ->andWhere('e.status = 1')
  690.             ->setParameters([':direction' => 'journal''date_end' => date('Y-m-d'time())])
  691.             ->orderBy('e.date_end''DESC')
  692.             ->getQuery();
  693.         $pagination $paginator->paginate(
  694.             $query$request->query->getInt('page'1), 30);
  695.         foreach ($pagination->getItems() as $item){
  696.             $this->editionFunction->getInfoEditionTeaser($item);
  697.         }
  698.         return $this->render('edition/lenta.html.twig', [
  699.             'editions' => $Editions,
  700.             'editionsPrev' => $pagination,
  701.             'metaTags' => $this->metaTags->getEditionJournalScience(),
  702.             'controller_name' => 'edition_nauch_journal_lenta'
  703.         ]);
  704.     }
  705.     /**
  706.      * @Route("/journal/stud/herald", name="edition_show_journal_student", methods={"GET","POST"})
  707.      */
  708.     public function show_journal_student()
  709.     {
  710.         $edition $this->em->getRepository(Edition::class)->getActualEdition('studmagazine');
  711.         $type '';
  712.         if(!empty($_GET['type']) && in_array($_GET['type'], ['articles''public'])) $type $_GET['type'];
  713.         $this->metaTags->setEditionInfo($edition);
  714.         $InfoEdition $this->editionFunction->getInfoEdition($edition);
  715.         $feedbacks $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
  716.             ->andWhere('f.status = 1')
  717.             ->andWhere('f.direction = :direction')
  718.             ->setParameter('direction'1)
  719.             ->orderBy('f.id''DESC')
  720.             ->setMaxResults(10)
  721.             ->getQuery()
  722.             ->getResult();
  723.         return $this->render('edition/show.html.twig', [
  724.             'editionInfo' => $InfoEdition,
  725.             'editionInfoFull' => true,
  726.             'type' => $type,
  727.             'feedbacks' => $feedbacks,
  728.         ]);
  729.     }
  730.     /**
  731.      * @Route("/journal/stud", name="edition_journal_stud_lenta", methods={"GET","POST"})
  732.      */
  733.     public function journal_stud_lenta(Request $requestPaginatorInterface $paginator)
  734.     {
  735.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  736.             ->andWhere('e.direction = :direction')
  737.             ->andWhere('e.date_end >= :date_end')
  738.             ->andWhere('e.status = 1')
  739.             ->setParameters([':direction' => 'studmagazine''date_end' => date('Y-m-d'time())])
  740.             ->orderBy('e.date_end''ASC')
  741.             ->getQuery();
  742.         $Editions $query->getResult();
  743.         foreach ($Editions as $key => $item) {
  744.             $this->editionFunction->getInfoEditionTeaser($item);
  745.         }
  746.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  747.             ->andWhere('e.direction = :direction')
  748.             ->andWhere('e.date_end < :date_end')
  749.             ->andWhere('e.status = 1')
  750.             ->setParameters([':direction' => 'studmagazine''date_end' => date('Y-m-d'time())])
  751.             ->orderBy('e.date_end''DESC')
  752.             ->getQuery();
  753.         $pagination $paginator->paginate(
  754.             $query$request->query->getInt('page'1), 30);
  755.         foreach ($pagination->getItems() as $item){
  756.             $this->editionFunction->getInfoEditionTeaser($item);
  757.         }
  758.         return $this->render('edition/lenta.html.twig', [
  759.             'editions' => $Editions,
  760.             'editionsPrev' => $pagination,
  761.             'metaTags' => $this->metaTags->getEditionJournalStud(),
  762.             'controller_name' => 'edition_journal_stud_lenta'
  763.         ]);
  764.     }
  765.     /**
  766.      * @Route("/journal", name="edition_journal_lenta", methods={"GET","POST"})
  767.      */
  768.     public function journal_lenta(Request $requestPaginatorInterface $paginator)
  769.     {
  770.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  771.             ->andWhere('e.direction IN (:direction)')
  772.             ->andWhere('e.date_end >= :date_end')
  773.             ->andWhere('e.status = 1')
  774.             ->setParameters([':direction' => ['studmagazine''journal'], 'date_end' => date('Y-m-d'time())])
  775.             ->orderBy('e.date_end''ASC')
  776.             ->getQuery();
  777.         $Editions $query->getResult();
  778.         foreach ($Editions as $key => $item) {
  779.             $this->editionFunction->getInfoEditionTeaser($item);
  780.         }
  781.         return $this->render('edition/journal.html.twig', [
  782.             'editions' => $Editions,
  783.             'metaTags' => $this->metaTags->getEditionJournal()
  784.         ]);
  785.     }
  786.     /**
  787.      * @Route("/young-scientist/researcher", name="edition_show_conf_student", methods={"GET","POST"})
  788.      */
  789.     public function show_conf_student()
  790.     {
  791.         $edition $this->em->getRepository(Edition::class)->getActualEdition('moluch');
  792.         $type '';
  793.         if(!empty($_GET['type']) && in_array($_GET['type'], ['articles''public'])) $type $_GET['type'];
  794.         $this->metaTags->setEditionInfo($edition);
  795.         $InfoEdition $this->editionFunction->getInfoEdition($edition);
  796.         $feedbacks $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
  797.             ->andWhere('f.status = 1')
  798.             ->andWhere('f.direction = :direction')
  799.             ->setParameter('direction'3)
  800.             ->orderBy('f.id''DESC')
  801.             ->setMaxResults(10)
  802.             ->getQuery()
  803.             ->getResult();
  804.         return $this->render('edition/show.html.twig', [
  805.             'editionInfo' => $InfoEdition,
  806.             'editionInfoFull' => true,
  807.             'type' => $type,
  808.             'feedbacks' => $feedbacks,
  809.         ]);
  810.     }
  811.     /**
  812.      * @Route("/young-scientist", name="edition_conf_student_lenta", methods={"GET","POST"})
  813.      */
  814.     public function conf_student_lenta(Request $requestPaginatorInterface $paginator)
  815.     {
  816.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  817.             ->andWhere('e.direction = :direction')
  818.             ->andWhere('e.date_end >= :date_end')
  819.             ->andWhere('e.status = 1')
  820.             ->setParameters([':direction' => 'moluch''date_end' => date('Y-m-d'time())])
  821.             ->orderBy('e.date_end''ASC')
  822.             ->getQuery();
  823.         $Editions $query->getResult();
  824.         foreach ($Editions as $key => $item) {
  825.             $this->editionFunction->getInfoEditionTeaser($item);
  826.         }
  827.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  828.             ->andWhere('e.direction = :direction')
  829.             ->andWhere('e.date_end < :date_end')
  830.             ->andWhere('e.status = 1')
  831.             ->setParameters([':direction' => 'moluch''date_end' => date('Y-m-d'time())])
  832.             ->orderBy('e.date_end''DESC')
  833.             ->getQuery();
  834.         $pagination $paginator->paginate(
  835.             $query$request->query->getInt('page'1), 30);
  836.         foreach ($pagination->getItems() as $item){
  837.             $this->editionFunction->getInfoEditionTeaser($item);
  838.         }
  839.         return $this->render('edition/lenta.html.twig', [
  840.             'editions' => $Editions,
  841.             'editionsPrev' => $pagination,
  842.             'metaTags' => $this->metaTags->getEditionYoungScientist(),
  843.             'controller_name' => 'edition_conf_student_lenta'
  844.         ]);
  845.     }
  846.     /**
  847.      * @Route("/monograph/modern-science", name="edition_show_mono", methods={"GET","POST"})
  848.      */
  849.     public function show_mono()
  850.     {
  851.         $edition $this->em->getRepository(Edition::class)->getActualEdition('mono');
  852.         $type '';
  853.         if(!empty($_GET['type']) && in_array($_GET['type'], ['articles''public'])) $type $_GET['type'];
  854.         $this->metaTags->setEditionInfo($edition);
  855.         $InfoEdition $this->editionFunction->getInfoEdition($edition);
  856.         $feedbacks $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
  857.             ->andWhere('f.status = 1')
  858.             ->andWhere('f.direction = :direction')
  859.             ->setParameter('direction'7)
  860.             ->orderBy('f.id''DESC')
  861.             ->setMaxResults(10)
  862.             ->getQuery()
  863.             ->getResult();
  864.         return $this->render('edition/show.html.twig', [
  865.             'editionInfo' => $InfoEdition,
  866.             'editionInfoFull' => true,
  867.             'type' => $type,
  868.             'feedbacks' => $feedbacks,
  869.         ]);
  870.     }
  871.     /**
  872.      * @Route("/monograph", name="edition_mono_lenta", methods={"GET","POST"})
  873.      */
  874.     public function mono_lenta(Request $requestPaginatorInterface $paginator)
  875.     {
  876.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  877.             ->andWhere('e.direction = :direction')
  878.             ->andWhere('e.date_end >= :date_end')
  879.             ->andWhere('e.status = 1')
  880.             ->setParameters([':direction' => 'mono''date_end' => date('Y-m-d'time())])
  881.             ->orderBy('e.date_end''ASC')
  882.             ->getQuery();
  883.         $Editions $query->getResult();
  884.         foreach ($Editions as $key => $item) {
  885.             $this->editionFunction->getInfoEditionTeaser($item);
  886.         }
  887.         $query $this->em->getRepository(Edition::class)->createQueryBuilder('e')
  888.             ->andWhere('e.direction = :direction')
  889.             ->andWhere('e.date_end < :date_end')
  890.             ->andWhere('e.status = 1')
  891.             ->setParameters([':direction' => 'mono''date_end' => date('Y-m-d'time())])
  892.             ->orderBy('e.date_end''DESC')
  893.             ->getQuery();
  894.         $pagination $paginator->paginate(
  895.             $query$request->query->getInt('page'1), 30);
  896.         foreach ($pagination->getItems() as $item){
  897.             $this->editionFunction->getInfoEditionTeaser($item);
  898.         }
  899.         return $this->render('edition/lenta.html.twig', [
  900.             'editions' => $Editions,
  901.             'editionsPrev' => $pagination,
  902.             'metaTags' => $this->metaTags->getEditionMonograph(),
  903.             'controller_name' => 'edition_mono_lenta'
  904.         ]);
  905.     }
  906. }