<?php
namespace App\Controller;
use App\Entity\Edition;
use App\Entity\Feedback;
use App\Entity\Zayavka;
use App\Entity\ZayavkaMono;
use App\Form\EditionType;
use App\Form\RussianPostType;
use App\Message\EditionSendEmailPdfMessage;
use App\Service\Edition\EditionAddGoogleTab;
use App\Service\EditionDate;
use App\Service\EditionFunction;
use App\Service\FileUploader;
use App\Service\MetaTags\MetaTags;
use App\Service\Path\Classes\PathEntity;
use App\Service\PdfGeneration\PdfGeneration;
use App\Service\Price;
use App\Service\RussianPost\RussianPostFunction;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Annotation\Route;
class EditionController extends AbstractController
{
private $editionDate;
private $editionFunction;
private $pdfGeneration;
private $pathEntity;
private $metaTags;
private $em;
private $bus;
public function __construct(EditionDate $editionDate, EditionFunction $editionFunction, PdfGeneration $pdfGeneration, PathEntity $pathEntity, MetaTags $metaTags, EntityManagerInterface $em, MessageBusInterface $bus)
{
$this->editionDate = $editionDate;
$this->editionFunction = $editionFunction;
$this->pdfGeneration = $pdfGeneration;
$this->pathEntity = $pathEntity;
$this->metaTags = $metaTags;
$this->em = $em;
$this->bus = $bus;
}
/**
* @Route("/admin/edition/ajax/get/{name}", name="edition_ajax_get", methods={"GET"})
*/
public function edition_ajax_get($name)
{
$editions = [];
$result = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->select('e.id, e.name, e.date_end')
->andWhere('e.name LIKE :name')
->setParameter('name', '%' . $name . '%')
->orderBy('e.name', 'ASC')
->getQuery()
->getArrayResult();
if ($result) {
foreach ($result as $item) {
$editions[] = ['name' => $item['name'] . ' (' . $item['date_end']->format('d.m.Y') . ') [' . $item['id'] . ']'];
}
}
return $this->json($editions ? $editions : FALSE);
}
/**
* @Route("/admin/edition", priority=11, name="edition_index", methods={"GET"})
*/
public function index(Request $request, PaginatorInterface $paginator): Response
{
$Editions = $this->em->getRepository(Edition::class)->createQueryBuilder('e')->orderBy('e.id', 'DESC');
$direction = [];
foreach ($this->getParameter('direction') as $key => $item) {
if (!empty($item['label'])) $direction[$item['label']] = $key;
}
$form = $this->createFormBuilder(['name' => ''], ['csrf_protection' => false])
->add('name', TextType::class, [
'required' => false,
'label' => 'Название конференции',
])
->add('direction', ChoiceType::class, [
'required' => false,
'label' => 'Конференция',
'choices' => $direction,
])
->add('active', ChoiceType::class, [
'required' => false,
'label' => 'Текущие выпуски',
'choices' => ['Да' => 1, 'Нет' => 0],
'placeholder' => 'Все'
])
->setMethod('GET')
->getForm();
if ($request->getMethod() == 'GET') {
$form->handleRequest($request);
$data = $form->getData();
}
if (isset($data['active'])) {
if($data['active'] == 0) {
$Editions->andWhere('e.date_end <= :time')->setParameter('time', date("Y-m-d 00:00:00", time()));
} elseif ($data['active'] == 1){
$Editions->andWhere('e.date_end >= :time')->setParameter('time', date("Y-m-d 00:00:00", time()));
}
}
if (!empty($data['name'])) {
$Editions->andWhere('e.name LIKE :title')
->setParameter('title', '%' . $data['name'] . '%');
}
if (!empty($data['direction'])) {
$Editions->andWhere('e.direction = :direction')
->setParameter('direction', $data['direction']);
}
$pagination = $paginator->paginate(
$Editions->getQuery(), $request->query->getInt('page', 1), 30);
$pagination->setTemplate('@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig');
return $this->render('admin/edition/index.html.twig', [
'editions' => $pagination,
'form' => $form->createView(),
]);
}
/**
* @Route("/admin/edition/{id}/price_update", priority=11, name="edition_price_update", methods={"GET","POST"}, requirements={"path"="\d+"})
*/
public function price_update(Edition $edition, Request $request, Price $price): Response
{
$edition->setPrice(serialize($price->getActualPrice($this->editionFunction->getEditionType($edition->getDirection()))));
$this->em->persist($edition);
$this->em->flush();
return $this->render('admin/edition/price_update.html.twig', [
'edition' => $edition
]);
}
/**
* @Route("/admin/edition/price_update/all", priority=11, name="edition_all_price_update", methods={"GET","POST"})
*/
public function all_price_update(Price $price): Response
{
$editions = $this->em->getRepository(Edition::class)->findAll();
foreach ($editions as $edition) {
$edition->setPrice(serialize($price->getActualPrice($this->editionFunction->getEditionType($edition->getDirection()))));
$this->em->persist($edition);
$this->em->flush();
}
return $this->render('admin/edition/all_price_update.html.twig', []);
}
/**
* @Route("/admin/edition/price_update/actual", priority=11, name="edition_actual_price_update", methods={"GET"})
*/
public function actual_price_update(Price $price): Response
{
$editions = $this->em->getRepository(Edition::class)->getActualEditions();
foreach ($editions as $edition) {
$edition->setPrice(serialize($price->getActualPrice($this->editionFunction->getEditionType($edition->getDirection()))));
$this->em->persist($edition);
$this->em->flush();
}
return $this->render('admin/edition/all_price_update.html.twig', []);
}
/**
* @Route("/admin/edition/{id}/article_parts", priority=11, name="edition_article_parts", methods={"GET","POST"}, requirements={"path"="\d+"})
*/
public function article_parts(Edition $edition, Request $request): Response
{
if (!empty($edition->getEditionPages()[1])) {
if ($edition->getDirection() == 'mono') {
$zayavka = $this->em->getRepository(ZayavkaMono::class)->createQueryBuilder('z')
->join('z.article', 'article')
->join('z.edition', 'edition')
->andWhere('edition.id = :id')
->setParameter('id', $edition->getId())
->andWhere('z.print_journal > 0')
->andWhere('article.id IS NOT NULL AND (article.part IS NULL OR article.part = 0)')
->orderBy('z.id', 'DESC')
->getQuery()
->getResult();
} else {
$zayavka = $this->em->getRepository(Zayavka::class)->createQueryBuilder('z')
->join('z.article', 'article')
->join('z.edition', 'edition')
->andWhere('edition.id = :id')
->setParameter('id', $edition->getId())
->andWhere('z.print_journal > 0')
->andWhere('article.id IS NOT NULL AND (article.part IS NULL OR article.part = 0)')
->orderBy('z.id', 'DESC')
->getQuery()
->getResult();
}
return $this->render('admin/edition/article_parts.html.twig', [
'zayavkas' => $zayavka,
'edition' => $edition,
]);
}
die('Данные заполнены');
}
/**
* @Route("/admin/edition/updategoogle", priority=11, name="edition_updateGoogle", methods={"GET","POST"})
*/
public function updateGoogle(EditionAddGoogleTab $editionAddGoogleTab): Response
{
return $this->render('admin/edition/updateGoogle.html.twig', [
'result' => $editionAddGoogleTab->addEdition()
]);
}
/**
* @Route("/admin/edition/new", priority=11, name="edition_new", methods={"GET","POST"})
*/
public function new(Request $request, FileUploader $fileUploader, EditionFunction $editionFunction): Response
{
$edition = new Edition();
$edition->setUser($this->getUser());
$form = $this->createForm(EditionType::class, $edition);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$edition->setCreated(time());
$edition->setUpdated(time());
$edition->setEmailSubscribe(FALSE);
$Cover = $form->get('cover')->getData();
if ($Cover) {
$CoverFileName = $fileUploader->upload($Cover, 'edition/cover/' . $editionFunction->getEditionType($edition->getDirection()));
$edition->setCover($CoverFileName);
}
$edition->setFile('edition/pdf/' . str_replace('/', '-', $edition->getDirection()) . '-' . $edition->getNumber() . '.pdf');
$this->em->persist($edition);
$this->em->flush();
$this->pathEntity->setPath($edition);
$this->pdfGeneration->createPdfEdition($edition);
return $this->redirectToRoute('edition_index');
}
return $this->render('admin/edition/new.html.twig', [
'edition' => $edition,
'form' => $form->createView(),
]);
}
/**
* @Route("/admin/edition/{id}/edit", priority=11, name="edition_edit", methods={"GET","POST"})
*/
public function edit(Request $request, Edition $edition, FileUploader $fileUploader, EditionFunction $editionFunction): Response
{
$form = $this->createForm(EditionType::class, $edition);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$edition->setUpdated(time());
$Cover = $form->get('cover')->getData();
if ($Cover) {
$CoverFileName = $fileUploader->upload($Cover, 'edition/cover/' . $editionFunction->getEditionType($edition->getDirection()));
if ($edition->getCover()) $fileUploader->delete($edition->getCover());
$edition->setCover($CoverFileName);
}
if($edition->getDirection() !== 'authorsmono') $this->pdfGeneration->createPdfEdition($edition);
if(!$edition->isSendEmailPdf()) {
if(!empty($edition->getEditionPages()[0]) && !empty($edition->getEditionPages()[0]->getFilepath()) && $edition->getDatePubl()->getTimestamp() > (time() - 86400 * 3)) {
$edition->setSendEmailPdf(1);
$this->bus->dispatch(new EditionSendEmailPdfMessage(['id' => $edition->getId()]));
}
}
$this->em->flush();
return $this->redirectToRoute('edition_index');
}
return $this->render('admin/edition/edit.html.twig', [
'edition' => $edition,
'form' => $form->createView(),
]);
}
/**
* @Route("/admin/edition/{id}", priority=11, name="edition_delete", methods={"DELETE"})
*/
public function delete(Request $request, Edition $edition): Response
{
if ($this->isCsrfTokenValid('delete' . $edition->getId(), $request->request->get('_token'))) {
$this->em->remove($edition);
$this->em->flush();
}
return $this->redirectToRoute('edition_index');
}
/**
* @Route("/admin/edition/{id}/pdf/update", priority=11, name="admin_pdf_update", methods={"GET"})
*/
public function admin_pdf_update(Edition $edition): Response
{
$this->pdfGeneration->createPdfEdition($edition);
echo '<a href="/' . $edition->getFile() . '">Ссылка на PDF</a>';
die();
return $this->redirect('/' . $edition->getFile());
}
/**
* @Route("/admin/edition/{id}/report_cert", priority=11, name="admin_edition_report", methods={"GET","POST"})
*/
public function admin_report(Edition $edition)
{
if ($edition) {
$filepath = $this->editionFunction->getReport($edition);
if (file_exists($filepath)) {
$path_info = pathinfo($filepath);
$filename = $path_info['basename'];
header('Content-Type: application/x-force-download; name="' . $filename . '"');
header("Content-Disposition: attachment; filename=$filename");
readfile($filepath);
} else {
header("HTTP/1.1 404 Not Found");
echo '404 Not Found';
}
}
die();
}
/**
* @Route("/admin/edition/{id}/postmail", priority=11, name="admin_edition_postmail", methods={"GET","POST"})
*/
public function admin_postmail(Edition $edition, Request $request, RussianPostFunction $russianPostFunction): Response
{
//Создаем форму для создания трек номеров в Почте России
$form = $this->createFormBuilder(['name' => ''], ['csrf_protection' => false])
->add('send', SubmitType::class, ['label' => 'Создать Рассылку'])
->getForm();
if ($request->getMethod() == 'POST') {
$form->handleRequest($request);
}
$batch = '<div class="new">Новые пакеты отправления дата сдачи: <span>' . date('Y-m-d', strtotime('next thursday')) . '</span></div>';
$batchId = [];
if ($PostMailBatch = $russianPostFunction->getBatch()) {
$batch = '<p><strong>Существующие пакеты отправлений:</strong></p><ul>';
foreach ($PostMailBatch as $key => $item) {
$batch .= '<li data-id="' . $item['batch-name'] . '" data-batch_name="' . $key . '"><strong>' . $key . '</strong> Номер пакета: ' . $item['batch-name'] . ' Дата сдачи в ОПС ' . $item['list-number-date'] . '</li>';
$batchId[] = $item['batch-name'];
}
$batch .= '</ul>';
}
$send_text = '';
if ($form->getClickedButton() && 'send' === $form->getClickedButton()->getName()) {
// Нажата кнопка send
$send_text = $russianPostFunction->creatPost($edition, $batchId);
} else {
foreach ($edition->getEditionPages() as $key => $item) {
$form->add('weight_journal_' . ($key + 1), TextType::class, [
'attr' => [
'class' => 'weight_journal',
'data-id' => ($key + 1)
],
'required' => false,
'label' => 'Вес сборника/журнала/монографии №' . ($key + 1),
]);
}
}
if($russianPosts = $russianPostFunction->getFormsEditionRussianPost($edition)) {
//массив с формами отправлений
$PostMailForms = [];
foreach ($russianPosts as $russianPost) {
$PostMailForms[] = $this->createForm(RussianPostType::class, $russianPost, [
'action' => empty($russianPost->getId()) ? $this->generateUrl('russianpost_new') : $this->generateUrl('russianpost_update', ['id' => $russianPost->getId()]),
'method' => 'POST',
])->createView();
}
}
return $this->render('admin/edition/postmail.html.twig', [
'PostMailForms' => $PostMailForms,
'form' => $form->createView(),
'batch' => $batch,
'send_text' => $send_text,
]);
}
/**
* @Route("/admin/edition/{id}", priority=11, name="admin_edition_show", methods={"GET"}, requirements={"path"="\d+"})
*/
public function admin_show(Edition $edition): Response
{
return $this->render('admin/edition/show.html.twig', [
'edition' => $edition,
]);
}
/**
* @Route("/stud-herald-jsonu3vb4jx", priority=11, name="edition_stud_herald_export", methods={"GET"})
*/
public function edition_stud_herald_export(): Response
{
$output = [];
$Editions = $this->em->getRepository(Edition::class)->getStudmagazine('studmagazine');
foreach ($Editions as $edition) {
$output[$edition->getId()] = array(
'number' => $edition->getNumber(),
'cover' => 'https://www.internauka.org/' . $edition->getCover(),
'elibrary' => $edition->getLinkElibrary(),
'pdf' => [],
'pages' => [],
'date_end' => $edition->getDateEnd()->format('c'),
'data_publ' => $edition->getDatePubl()->format('c'),
);
}
if (!empty($edition->getEditionPages())) {
foreach ($edition->getEditionPages() as $editionPage) {
if (!empty($editionPage->getFilepath())) $output[$edition->getId()]['pdf'][] = $editionPage->getFilepath();
if (!empty($editionPage->getPages())) $output[$edition->getId()]['pages'][] = $editionPage->getPages();
}
}
return $this->json($output);
}
/**
* @Route("/archive", name="edition_archive", methods={"GET"})
*/
public function edition_archive(Request $request, PaginatorInterface $paginator)
{
$defaultData = array('title' => '');
$years = ['За все время' => 'all'] + array_combine(range(2012, date('Y')), range(2012, date('Y')));
$form = $this->createFormBuilder($defaultData, ['csrf_protection' => false])
->add('edition', ChoiceType::class, [
'choices' => ['Все издания' => 'all', 'Журнал' => 'journal', 'Книга' => 'authorsmono', 'Конференция' => 'conf', 'Монография' => 'mono'],
'required' => true,
'label' => 'Тип издания',
])
->add('year', ChoiceType::class, [
'choices' => $years,
'required' => true,
'label' => 'Год издания',
])
->add('articles', TextType::class, [
'required' => false,
'label' => 'Название статьи/главы',
])
->add('authors', TextType::class, [
'required' => false,
'label' => 'ФИО автора',
])
->setMethod('GET')
->getForm();
$data = [];
if ($request->getMethod() == 'GET') {
$form->handleRequest($request);
$data = $form->getData();
}
$editions = $this->em->getRepository(Edition::class)->getArchive($data);
$pagination = $paginator->paginate(
$editions, $request->query->getInt('page', 1), 30);
if (!empty($data['articles'])) {
foreach ($pagination as $edition) {
foreach ($edition->getArticles() as $article) {
$title = preg_replace("/(" . $data['articles'] . ")/ius", "<span>\\1</span>", $article->getTitle());
$article->setTitle($title);
if (!empty($data['authors'])) {
foreach ($article->getArticleAuthors() as $articleAuthor) {
$name = preg_replace("/(" . $data['authors'] . ")/ius", "<span>\\1</span>", $articleAuthor->getAuthors()->getName());
$articleAuthor->getAuthors()->setName($name);
}
foreach ($article->getArticleScidirectors() as $articleAuthor) {
$name = preg_replace("/(" . $data['authors'] . ")/ius", "<span>\\1</span>", $articleAuthor->getAuthors()->getName());
$articleAuthor->getAuthors()->setName($name);
}
}
}
}
}
return $this->render('edition/archive.html.twig', [
'editions' => $pagination,
'form' => $form->createView(),
'metaTags' => $this->metaTags->getEditionArchive(),
]);
}
/**
* Убираем что бы небыло дублей@Route("/edition/{id}", name="edition_show", methods={"GET"})
*/
public function show($id): Response
{
$edition = $this->em->getRepository(Edition::class)->find($id);
if ($edition->getStatus()) {
$type = '';
if(!empty($_GET['type']) && in_array($_GET['type'], ['articles', 'public'])) $type = $_GET['type'];
$this->metaTags->setEdition($edition);
$InfoEdition = $this->editionFunction->getInfoEdition($edition);
$direction = 0;
if($InfoEdition['type'] == 'studJournal'){
$direction = 1;
} elseif($InfoEdition['type'] == 'journal'){
$direction = 2;
} elseif($InfoEdition['type'] == 'studConf'){
$direction = 3;
} elseif($InfoEdition['type'] == 'nauchConf' || $InfoEdition['type'] == 'worldConf'){
$direction = 4;
} elseif($InfoEdition['type'] == 'mono'){
$direction = 7;
}
$feedbacks = $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
->andWhere('f.status = 1')
->andWhere('f.direction = :direction')
->setParameter('direction', $direction)
->orderBy('f.id', 'DESC')
->setMaxResults(10)
->getQuery()
->getResult();
$template = 'edition/show.html.twig';
if ($InfoEdition['type'] == 'worldConf') $template = 'edition/full_show.html.twig';
return $this->render($template, [
'editionInfo' => $InfoEdition,
'type' => $type,
'feedbacks' => $feedbacks,
]);
}
throw $this->createNotFoundException('404');
}
/**
* @Route("/conf/{path}", name="edition_show_conf", methods={"GET","POST"})
*/
public function show_conf($path)
{
$directionParameter = $this->getParameter('direction');
foreach ($directionParameter as $key => $item) {
if (!empty($item['path_page'])) {
if ($item['path_page'] == 'conf/' . $path) {
$direction = $key;
break;
}
}
}
if (!empty($direction)) {
$edition = $this->em->getRepository(Edition::class)->getActualEdition($direction);
$type = '';
if(!empty($_GET['type']) && in_array($_GET['type'], ['articles', 'public'])) $type = $_GET['type'];
$this->metaTags->setEditionInfo($edition);
$InfoEdition = $this->editionFunction->getInfoEdition($edition);
$direction = 0;
if($InfoEdition['type'] == 'studJournal'){
$direction = 1;
} elseif($InfoEdition['type'] == 'journal'){
$direction = 2;
} elseif($InfoEdition['type'] == 'studConf'){
$direction = 3;
} elseif($InfoEdition['type'] == 'nauchConf' || $InfoEdition['type'] == 'worldConf'){
$direction = 4;
} elseif($InfoEdition['type'] == 'mono'){
$direction = 7;
}
$feedbacks = $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
->andWhere('f.status = 1')
->andWhere('f.direction = :direction')
->setParameter('direction', $direction)
->orderBy('f.id', 'DESC')
->setMaxResults(10)
->getQuery()
->getResult();
$template = 'edition/show.html.twig';
if ($InfoEdition['type'] == 'worldConf') $template = 'edition/full_show.html.twig';
return $this->render($template, [
'editionInfo' => $InfoEdition,
'editionInfoFull' => true,
'type' => $type,
'feedbacks' => $feedbacks,
]);
}
throw $this->createNotFoundException('404');
}
/**
* @Route("/conference", name="edition_conference_lenta", methods={"GET","POST"})
*/
public function conference_lenta(Request $request, PaginatorInterface $paginator)
{
$direction = ['spain', 'netherlands', 'usaconference'];
$directionParameter = $this->getParameter('direction');
foreach ($directionParameter as $key => $item) {
if (strpos($key, 'conf') === 0) {
$direction[] = $key;
}
}
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction IN (:direction)')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => $direction, 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$EditionsTmp = $query->getResult();
$Editions = [];
foreach ($EditionsTmp as $key => $item) {
if (empty($Editions[$item->getDirection()])) $Editions[$item->getDirection()] = $this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/conference.html.twig', [
'editions' => $Editions,
'metaTags' => $this->metaTags->getEditionConference(),
'controller_name' => 'edition_conference_lenta'
]);
}
/**
* @Route("/conference/{path}", name="edition_conference_science", methods={"GET","POST"})
*/
public function conference_science($path, Request $request, PaginatorInterface $paginator)
{
$path_arr = [
'arhitektura' => ['conf/tech', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'astronomiya' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'biologiya' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'veterinarnye-nauki' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'geografiya' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'geologiya' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'informacionnye-tehnologii' => ['conf/math', 'conf/tech', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'iskusstvovedenie' => ['conf/philology', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'istoriya' => ['conf/social', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'kulturologiya' => ['conf/philology', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'matematika' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'medicina' => ['conf/med', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'menedzhment' => ['conf/economy', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'pedagogika' => ['conf/pedagogy', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'politologiya' => ['conf/social', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'psihologiya' => ['conf/pedagogy', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'selskohozyaystvennye-nauki' => ['spain', 'netherlands', 'usaconference', 'conf/inno'],
'sociologiya' => ['conf/social', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'tehnicheskie-nauki' => ['conf/tech', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'farmacevticheskie-nauki' => ['conf/med', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'fizika' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'filologiya' => ['conf/philology', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'filosofiya' => ['conf/social', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'himiya' => ['conf/math', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'ekonomika' => ['conf/economy', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
'yurisprudenciya' => ['conf/law', 'spain', 'netherlands', 'usaconference', 'conf/inno'],
];
if (!empty($path_arr[$path])) {
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction IN (:direction)')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => $path_arr[$path], 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$Editions = $query->getResult();
foreach ($Editions as $key => $item) {
$this->editionFunction->getInfoEditionTeaser($item);
}
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction IN (:direction)')
->andWhere('e.date_end < :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => $path_arr[$path], 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'DESC')
->getQuery();
$pagination = $paginator->paginate(
$query, $request->query->getInt('page', 1), 30);
foreach ($pagination->getItems() as $item){
$this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/lenta.html.twig', [
'editions' => $Editions,
'editionsPrev' => $pagination,
'metaTags' => $this->metaTags->getEditionConferenceScience($path),
'controller_name' => 'edition_conference_science'
]);
}
throw $this->createNotFoundException('404');
}
/**
* @Route("/journal/science/internauka", name="edition_show_nauch_journal", methods={"GET","POST"})
*/
public function show_nauch_journal()
{
$edition = $this->em->getRepository(Edition::class)->getActualEdition('journal');
$type = '';
if(!empty($_GET['type']) && in_array($_GET['type'], ['articles', 'public'])) $type = $_GET['type'];
$this->metaTags->setEditionInfo($edition);
$InfoEdition = $this->editionFunction->getInfoEdition($edition);
$feedbacks = $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
->andWhere('f.status = 1')
->andWhere('f.direction = :direction')
->setParameter('direction', 2)
->orderBy('f.id', 'DESC')
->setMaxResults(10)
->getQuery()
->getResult();
return $this->render('edition/show.html.twig', [
'editionInfo' => $InfoEdition,
'editionInfoFull' => true,
'type' => $type,
'feedbacks' => $feedbacks,
]);
}
/**
* @Route("/journal/science", name="edition_nauch_journal_lenta", methods={"GET","POST"})
*/
public function nauch_journal_lenta(Request $request, PaginatorInterface $paginator)
{
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'journal', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$Editions = $query->getResult();
foreach ($Editions as $key => $item) {
$this->editionFunction->getInfoEditionTeaser($item);
}
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end < :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'journal', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'DESC')
->getQuery();
$pagination = $paginator->paginate(
$query, $request->query->getInt('page', 1), 30);
foreach ($pagination->getItems() as $item){
$this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/lenta.html.twig', [
'editions' => $Editions,
'editionsPrev' => $pagination,
'metaTags' => $this->metaTags->getEditionJournalScience(),
'controller_name' => 'edition_nauch_journal_lenta'
]);
}
/**
* @Route("/journal/stud/herald", name="edition_show_journal_student", methods={"GET","POST"})
*/
public function show_journal_student()
{
$edition = $this->em->getRepository(Edition::class)->getActualEdition('studmagazine');
$type = '';
if(!empty($_GET['type']) && in_array($_GET['type'], ['articles', 'public'])) $type = $_GET['type'];
$this->metaTags->setEditionInfo($edition);
$InfoEdition = $this->editionFunction->getInfoEdition($edition);
$feedbacks = $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
->andWhere('f.status = 1')
->andWhere('f.direction = :direction')
->setParameter('direction', 1)
->orderBy('f.id', 'DESC')
->setMaxResults(10)
->getQuery()
->getResult();
return $this->render('edition/show.html.twig', [
'editionInfo' => $InfoEdition,
'editionInfoFull' => true,
'type' => $type,
'feedbacks' => $feedbacks,
]);
}
/**
* @Route("/journal/stud", name="edition_journal_stud_lenta", methods={"GET","POST"})
*/
public function journal_stud_lenta(Request $request, PaginatorInterface $paginator)
{
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'studmagazine', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$Editions = $query->getResult();
foreach ($Editions as $key => $item) {
$this->editionFunction->getInfoEditionTeaser($item);
}
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end < :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'studmagazine', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'DESC')
->getQuery();
$pagination = $paginator->paginate(
$query, $request->query->getInt('page', 1), 30);
foreach ($pagination->getItems() as $item){
$this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/lenta.html.twig', [
'editions' => $Editions,
'editionsPrev' => $pagination,
'metaTags' => $this->metaTags->getEditionJournalStud(),
'controller_name' => 'edition_journal_stud_lenta'
]);
}
/**
* @Route("/journal", name="edition_journal_lenta", methods={"GET","POST"})
*/
public function journal_lenta(Request $request, PaginatorInterface $paginator)
{
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction IN (:direction)')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => ['studmagazine', 'journal'], 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$Editions = $query->getResult();
foreach ($Editions as $key => $item) {
$this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/journal.html.twig', [
'editions' => $Editions,
'metaTags' => $this->metaTags->getEditionJournal()
]);
}
/**
* @Route("/young-scientist/researcher", name="edition_show_conf_student", methods={"GET","POST"})
*/
public function show_conf_student()
{
$edition = $this->em->getRepository(Edition::class)->getActualEdition('moluch');
$type = '';
if(!empty($_GET['type']) && in_array($_GET['type'], ['articles', 'public'])) $type = $_GET['type'];
$this->metaTags->setEditionInfo($edition);
$InfoEdition = $this->editionFunction->getInfoEdition($edition);
$feedbacks = $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
->andWhere('f.status = 1')
->andWhere('f.direction = :direction')
->setParameter('direction', 3)
->orderBy('f.id', 'DESC')
->setMaxResults(10)
->getQuery()
->getResult();
return $this->render('edition/show.html.twig', [
'editionInfo' => $InfoEdition,
'editionInfoFull' => true,
'type' => $type,
'feedbacks' => $feedbacks,
]);
}
/**
* @Route("/young-scientist", name="edition_conf_student_lenta", methods={"GET","POST"})
*/
public function conf_student_lenta(Request $request, PaginatorInterface $paginator)
{
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'moluch', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$Editions = $query->getResult();
foreach ($Editions as $key => $item) {
$this->editionFunction->getInfoEditionTeaser($item);
}
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end < :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'moluch', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'DESC')
->getQuery();
$pagination = $paginator->paginate(
$query, $request->query->getInt('page', 1), 30);
foreach ($pagination->getItems() as $item){
$this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/lenta.html.twig', [
'editions' => $Editions,
'editionsPrev' => $pagination,
'metaTags' => $this->metaTags->getEditionYoungScientist(),
'controller_name' => 'edition_conf_student_lenta'
]);
}
/**
* @Route("/monograph/modern-science", name="edition_show_mono", methods={"GET","POST"})
*/
public function show_mono()
{
$edition = $this->em->getRepository(Edition::class)->getActualEdition('mono');
$type = '';
if(!empty($_GET['type']) && in_array($_GET['type'], ['articles', 'public'])) $type = $_GET['type'];
$this->metaTags->setEditionInfo($edition);
$InfoEdition = $this->editionFunction->getInfoEdition($edition);
$feedbacks = $this->em->getRepository(Feedback::class)->createQueryBuilder('f')
->andWhere('f.status = 1')
->andWhere('f.direction = :direction')
->setParameter('direction', 7)
->orderBy('f.id', 'DESC')
->setMaxResults(10)
->getQuery()
->getResult();
return $this->render('edition/show.html.twig', [
'editionInfo' => $InfoEdition,
'editionInfoFull' => true,
'type' => $type,
'feedbacks' => $feedbacks,
]);
}
/**
* @Route("/monograph", name="edition_mono_lenta", methods={"GET","POST"})
*/
public function mono_lenta(Request $request, PaginatorInterface $paginator)
{
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end >= :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'mono', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'ASC')
->getQuery();
$Editions = $query->getResult();
foreach ($Editions as $key => $item) {
$this->editionFunction->getInfoEditionTeaser($item);
}
$query = $this->em->getRepository(Edition::class)->createQueryBuilder('e')
->andWhere('e.direction = :direction')
->andWhere('e.date_end < :date_end')
->andWhere('e.status = 1')
->setParameters([':direction' => 'mono', 'date_end' => date('Y-m-d', time())])
->orderBy('e.date_end', 'DESC')
->getQuery();
$pagination = $paginator->paginate(
$query, $request->query->getInt('page', 1), 30);
foreach ($pagination->getItems() as $item){
$this->editionFunction->getInfoEditionTeaser($item);
}
return $this->render('edition/lenta.html.twig', [
'editions' => $Editions,
'editionsPrev' => $pagination,
'metaTags' => $this->metaTags->getEditionMonograph(),
'controller_name' => 'edition_mono_lenta'
]);
}
}