src/Controller/SearchController.php line 645

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Category;
  4. use App\Entity\DataReuters;
  5. use App\Entity\DataScopus;
  6. use App\Entity\DataThomsonMeta;
  7. use App\Entity\DataTScopus;
  8. use App\Entity\Journal;
  9. use App\Entity\Search;
  10. use App\Form\SearchType;
  11. use App\Repository\DataThomsonMetaRepository;
  12. use App\Repository\JournalRepository;
  13. use App\Service\ServiceForJournalFinder;
  14. use Doctrine\ORM\EntityManagerInterface;
  15. use Knp\Component\Pager\PaginatorInterface;
  16. use Symfony\Component\HttpFoundation\Request;
  17. use Symfony\Component\Routing\Annotation\Route;
  18. use Symfony\Component\Serializer\SerializerInterface;
  19. use Symfony\Component\HttpFoundation\JsonResponse;
  20. /**
  21.  * Class SearchController
  22.  *
  23.  * @package App\Controller
  24.  */
  25. class SearchController extends BaseController
  26. {
  27.     private $journalFinder;
  28.     
  29.     /** @var EntityManagerInterface */
  30.     private $entityManager;
  31.     /**
  32.      * @var PaginatorInterface
  33.      */
  34.     private $paginator;
  35.     /**
  36.      * SearchController constructor.
  37.      *
  38.      * @param EntityManagerInterface $entityManager
  39.      * @param PaginatorInterface $paginator
  40.      */
  41.     private $serializer;
  42.     public function __construct(EntityManagerInterface $entityManagerPaginatorInterface $paginatorServiceForJournalFinder $srJfinder,SerializerInterface $serializer)
  43.     {
  44.         $this->entityManager $entityManager;
  45.         $this->paginator $paginator;
  46.         $this->journalFinder$srJfinder;
  47.         $this->serializer $serializer;
  48.     }
  49.     /**
  50.      *
  51.      * @Route("/query", name="data_search_by_several_values")
  52.      */
  53.     public function searchByValue(Request $requestJournalRepository $journalRepositoryPaginatorInterface $paginator)
  54.     {
  55.         $searchTerm $request->get("searchValue"null);
  56.         $searchOption $request->get("searchOption""journal");
  57.         // searchterm has separator for multiple values
  58.         $separators = array("-""/"";"",""|""_");
  59.         $containsSeparator false;
  60.         $separatorChar "";
  61.         foreach ($separators as $separator) {
  62.             if (strpos($searchTerm$separator) !== false) {
  63.                 $containsSeparator true;
  64.                 $separatorChar $separator;
  65.                 break;
  66.             }
  67.         }
  68.          if($searchTerm$searchTerm=trim($searchTerm);
  69.         if ($searchTerm && 'journal' === $searchOption) {
  70.             $journalExists $journalRepository->findOneBy(['title' => $searchTerm]);
  71.             if ($containsSeparator && !$journalExists) {
  72.                 $searchkeywords explode($separatorChar$searchTerm);
  73.                 $searchkeywords array_map('trim'$searchkeywords);
  74.                 $searchTerm $searchkeywords;
  75.             }
  76.             $page $request->get("p"1);
  77.             $perpage 10;
  78.             $journals $paginator->paginate($journalRepository->search($searchTerm, [], $page), $page10);
  79.             $total=$journalRepository->countSearch($searchTerm, [], $page);
  80.             $pages intval(ceil($total/$perpage));
  81.             return $this->render('search/journal-results.html.twig',
  82.                 [
  83.                     'journals' => $journals,
  84.                     'page' => $page,
  85.                     "pages"=>$pages,
  86.                     'searchTerm' => $searchTerm,
  87.                     'searchOption' => $searchOption,
  88.                     'total'=>$total
  89.                 ]);
  90.         }
  91.        elseif ($searchOption=="author") {
  92.            return $this->redirectToRoute('get_authors', ['authorValue' => $searchTerm]);
  93.        }
  94.         else{
  95.             return $this->redirect('/');
  96.         }
  97.     }
  98.         /**
  99.      *
  100.      * @Route("api/query", name="data_search_by_several_values_api")
  101.      */
  102.     public function searchByValueAPI(Request $requestJournalRepository $journalRepositoryPaginatorInterface $paginator)
  103.     {
  104.         $searchTerm $request->get("searchValue"null);
  105.         $searchOption $request->get("searchOption""journal");
  106.         if($searchTerm$searchTerm=trim($searchTerm);
  107.         if ($searchTerm && 'journal' === $searchOption) {
  108.             $page $request->get("page"1);
  109.             $total=$journalRepository->countSearch($searchTerm, [], $page);
  110.             $journals $paginator->paginate($journalRepository->search($searchTerm, [], $page), $page50);
  111.             // return $this->render('search/journal-results.html.twig', ['journals' => $journals]);
  112.             return $this->json(['journals' => $journals]);
  113.         }
  114.         elseif ($searchOption == "author") {
  115.             return $this->redirectToRoute('get_authors', ['authorValue' => $searchTerm]);
  116.         }
  117.         else{
  118.             return $this->redirect('/');
  119.         }
  120.     }
  121.     /**
  122.      * Lists all data_t_scopus entities.
  123.      *
  124.      * @Route("/show-journal/{eISSN}", name="data_t_scopus_results")
  125.      */
  126.     public function findValue($eISSNRequest $request)
  127.     {
  128.         $objet = new Search();
  129.         $data_t_scopus = array();
  130.         $data_reuters = array();
  131.         $data_thomson_reuters = array();
  132.         $pagination_slide=null;
  133.         $topjournallistScopus=null;
  134.         $var_title="";
  135.         $form $this->createForm(SearchType::class, $objet);
  136.         $form->handleRequest($request);
  137.         if ($form->isSubmitted() && $form->isValid()) {
  138.             $eISSN $form->get("searchValue")->getData();
  139.         }
  140.         $emS $this->getDoctrine()->getManager();
  141.         $em $this->entityManager->getRepository(DataTScopus::class);
  142.         $em2 $this->entityManager->getRepository(DataReuters::class);
  143.         $em3 $this->entityManager->getRepository(DataThomsonMeta::class);
  144.         $eISSNT $eISSN;
  145.         $eISSNS $eISSN;
  146.         $pos strpos($eISSN"-");
  147.         $c_number preg_match('/\\d/'$eISSN);
  148.         if ($c_number == 1) {
  149.             if (strlen($eISSN) == || strlen($eISSN) == 8) {
  150.                 if ($pos !== false) {
  151.                     $eISSNS str_replace("-"""$eISSN);
  152.                 } else {
  153.                     $eISSNT substr_replace($eISSN"-"40);
  154.                     $eISSNS str_replace("-"""$eISSN);
  155.                 }
  156.                 $data_t_scopus $em->findInScopusByIssn($eISSNS$emS);
  157.                 $data_reuters $em2->findInThomsonByIssn($eISSNT$emS);
  158.                 $data_thomson_reuters $em3->findInThomsonReutersByIssn($eISSNT$emS);
  159.                 if ($data_t_scopus != null$var_title=$data_t_scopus->getTitle();
  160.                 if ($data_t_scopus == null && $data_reuters != null) {
  161.                     if ($data_reuters->getEISSN() == $eISSNT && $data_reuters->getISSN() != null$eISSNS $data_reuters->getISSN();
  162.                     if ($data_reuters->getISSN() == $eISSNT && $data_reuters->getEISSN() != null$eISSNS $data_reuters->getEISSN();
  163.                     $data_t_scopus $em->findInScopusByIssn($eISSNS$emS);
  164.                 }
  165.                 if ($data_t_scopus != null && $data_reuters == null) {
  166.                     if ($data_t_scopus->getEISSN() == $eISSNS && $data_t_scopus->getPrintISSN() != null$eISSNT $data_t_scopus->getPrintISSN();
  167.                     if ($data_t_scopus->getPrintISSN() == $eISSNS && $data_t_scopus->getEISSN() != null$eISSNT $data_t_scopus->getEISSN();
  168.                     $eISSNT substr_replace($eISSNT"-"40);
  169.                     $data_reuters $em2->findInThomsonByIssn($eISSNT$emS);
  170.                     if ($data_reuters == null) {
  171.                         $eISSNT $data_t_scopus->getTitle();
  172.                         $var_title=$eISSNT;
  173.                         $eISSNT str_replace("&""and"$eISSNT);
  174.                         $data_reuters $em2->findInThomsonByTitle($eISSNT$emS);
  175.                     }
  176.                 }
  177.                 if ($data_thomson_reuters != null && $data_reuters == null && $data_t_scopus == null) {
  178.                     if ($data_thomson_reuters->getEISSN() == $eISSNT && $data_thomson_reuters->getEISSN() != null   && $data_thomson_reuters->getEISSN() != "null"$eISSNS $data_thomson_reuters->getEISSN();
  179.                     if ($data_thomson_reuters->getISSN() == $eISSNT && $data_thomson_reuters->getISSN() != null && $data_thomson_reuters->getISSN() != "null"$eISSNS $data_thomson_reuters->getISSN();
  180.                     $data_thomson_reuters $em3->findInThomsonReutersByIssn($eISSNS$emS);
  181.                 }
  182.             }
  183.         }
  184.         else {
  185.             $data_t_scopus $em->findScopusSeveralResultByTitle($eISSNS$emS);
  186.             if (sizeof($data_t_scopus) == 1) {
  187.                 $var_title=$data_t_scopus->getTitle();
  188.                 $eISSNT str_replace("&""and"$eISSN);
  189.                 $data_t_scopus $em->findInScopusByTitle($eISSNS$emS);
  190.                 $data_reuters $em2->findInThomsonByTitle($eISSNT$emS);
  191.                 if ($data_t_scopus == null && $data_reuters != null) {
  192.                     if ($data_reuters->getISSN() != null$eISSNS $data_reuters->getISSN();
  193.                     $eISSNS str_replace("-"""$eISSNS);
  194.                     $data_t_scopus $em->findInScopusByIssn($eISSNS$emS);
  195.                     if ($data_t_scopus) {
  196.                         if ($data_reuters->getEISSN() != null$eISSNS $data_reuters->getEISSN();
  197.                         $eISSNS str_replace("-"""$eISSNS);
  198.                         $data_t_scopus $em->findInScopusByIssn($eISSNS$emS);
  199.                     }
  200.                 }
  201.                 if ($data_t_scopus != null && $data_reuters == null) {
  202.                     if ($data_t_scopus->getPrintISSN() != null$eISSNT $data_t_scopus->getPrintISSN();
  203.                     $eISSNT=str_replace("-"""$eISSNT);
  204.                     $eISSNT substr_replace($eISSNT"-"40);
  205.                     $data_reuters $em2->findInThomsonByIssn($eISSNT$emS);
  206.                     if ($data_reuters == null) {
  207.                         if ($data_t_scopus->getEISSN() != null$eISSNT $data_t_scopus->getEISSN();
  208.                         $eISSNT=str_replace("-"""$eISSNT);
  209.                         $eISSNT substr_replace($eISSNT"-"40);
  210.                         $data_reuters $em2->findInThomsonByIssn($eISSNT$emS);
  211.                     }
  212.                     if ($data_reuters == null) {
  213.                         $eISSNT $data_t_scopus->getTitle();
  214.                         $eISSNT $eISSNT str_ireplace("&""and"$eISSN);
  215.                         $data_reuters $em2->findInThomsonByTitle($eISSNT$emS);
  216.                     }
  217.                 }
  218.             }
  219.         }
  220.         // ajouter le 12/05/2020
  221.         //echo $var_title;
  222.         if($var_title!="")
  223.             $pagination_slide=$this->journalFinder->similarResult($var_title);
  224.         $topjournallistWebofs=$em2->selectTopListWeb($emS);
  225.         $topjournallistScopus=$em->selectTopListScopus($emS);
  226.         $samePublisher=[];
  227.         $sameCategorie=[];
  228.        if($data_t_scopus && $data_t_scopus->getPublisher()) {
  229.            $samePublisher $em->samePublisher($data_t_scopus);
  230.            /** @var DataTScopus $data_t_scopus */
  231.        } if($data_t_scopus && $data_t_scopus->getSubjectArea()) {
  232.            $sameCategorie $em->sameCategory($data_t_scopus);
  233.        }
  234.         //fin de modification 10/05
  235.         return $this->render('default/searchV.html.twig', [
  236.             'form' => $form->createView(),
  237.             'data_reuter' => $data_reuters,
  238.             'data_t_scopus' => $data_t_scopus,
  239.             'data_thomson_reuters' => $data_thomson_reuters,
  240.             'eISSN' => $eISSN,
  241.             'tpjlistWebof'=>$topjournallistWebofs,
  242.             'tpjlistScopus'=>$topjournallistScopus,
  243.             'paginationR'=>$pagination_slide,
  244.             'adv'=>true,
  245.             'samePublisher'=>$samePublisher,
  246.             'sameCategorie'=>$sameCategorie
  247.         ]);
  248.     }
  249.     /**
  250.      * Lists all data_t_scopus entities.
  251.      *
  252.      * @Route("/advanced-search", name="advanced_search_scopus_web_ofs")
  253.      */
  254.     public function advanced_search_params()
  255.     {
  256.         $data_t_scopus null;
  257.         $data_reuters null;
  258.         $data_t_advanced_scopus null;
  259.         $data_advanced_reuters null;
  260.         $categories=null;
  261.         $publishers=null;
  262.         $var_title="";
  263.         $emS $this->getDoctrine()->getManager();
  264.         $em $this->entityManager->getRepository(Journal::class);
  265.         $categories=$em->selectALLCategories($emS);
  266.         $publishers=$em->selectALLPublishers($emS);
  267.         $show_advanced=1;
  268.         //echo sizeof($publishers);
  269.         return $this->render('default/searchV.html.twig', [
  270.             'data_reuter' => $data_reuters,
  271.             'data_t_scopus' => $data_t_scopus,
  272.             //'data_reuter_advanced' => $data_advanced_reuters,
  273.             //'data_t_scopus_advanced' => $data_t_advanced_scopus,
  274.             'listcategories'=>$categories,
  275.             'listpublishers'=>$publishers,
  276.             'show_ad'=>$show_advanced
  277.         ]);
  278.     }
  279.      /**
  280.      * Lists all data_t_scopus entities.
  281.      *
  282.      * @Route("/api/advanced-search", name="advanced_search_scopus_web")
  283.      */
  284.     public function advanced_search_params_API()
  285.     {
  286.         $data_t_scopus null;
  287.         $data_reuters null;
  288.         $data_t_advanced_scopus null;
  289.         $data_advanced_reuters null;
  290.         $categories=null;
  291.         $publishers=null;
  292.         $var_title="";
  293.         $emS $this->getDoctrine()->getManager();
  294.         $em $this->entityManager->getRepository(Journal::class);
  295.         $emC $this->entityManager->getRepository(Category::class);
  296.         $categories=$emC->selectALLCategories($emS);
  297.         $publishers=$em->selectALLPublishers($emS);
  298.         $show_advanced=1;
  299.         return $this->json([
  300.             'data_reuter' => $data_reuters,
  301.             'data_t_scopus' => $data_t_scopus,
  302.             'listcategories'=>$categories,
  303.             'listpublishers'=>$publishers,
  304.             'show_ad'=>$show_advanced
  305.         ]);
  306.     }
  307.      /**
  308.      * Lists all data_t_scopus entities.
  309.      *
  310.      * @Route("/api/categorie/advanced-search", name="advanced_search_params_API_categorie")
  311.      */
  312.     public function advanced_search_params_API_categorie()
  313.     {
  314.         $data_t_scopus null;
  315.         $data_reuters null;
  316.         $data_t_advanced_scopus null;
  317.         $data_advanced_reuters null;
  318.         $categories=null;
  319.         $publishers=null;
  320.         $var_title="";
  321.         $emS $this->getDoctrine()->getManager();
  322.         $em $this->entityManager->getRepository(DataTScopus::class);
  323.         $categories=$em->selectALLCategories($emS);
  324.         $publishers=$em->selectALLPublishers($emS);
  325.         $show_advanced=1;
  326.         return $this->json([
  327.           
  328.             'listcategories'=>$categories,
  329.         ]);
  330.     }
  331.     /**
  332.      *
  333.      * @Route("/advanced_query", name="data__advanced_search_by_several_params")
  334.      */
  335.     public function advancedsearchByParams(Request $request)
  336.     {
  337.         $emS $this->getDoctrine()->getManager();
  338.         $em $this->entityManager->getRepository(DataTScopus::class);
  339.         $em2 $this->entityManager->getRepository(DataReuters::class);
  340.         $categories=$em->selectALLCategories($emS);
  341.         $publishers=$em->selectALLPublishers($emS);
  342.         $objet = new Search();
  343.         $data_t_advanced_scopus null;
  344.         $data_advanced_reuters null;
  345.         $data_t_scopus = array();
  346.         $data_intermediate= array();
  347.         $data_reuters = array();
  348.         $sjr_value=0;
  349.         $show_advanced=1;
  350.         $form $this->createForm(SearchType::class, $objet);
  351.         $publisher$request->get('name_of_publisher');
  352.         $subject_area=$request->get('subjectarea');
  353.         $openaccess_yes$request->get('yes');
  354.         $openaccess_no$request->get('no');
  355.         $j=0;
  356.         $ta_openaccs=null;
  357.         if($openaccess_yes=="yes"){
  358.             $ta_openaccs[$j]="YES";
  359.             $j=$j+1;
  360.         }
  361.         if($openaccess_no=="no"){
  362.             $ta_openaccs[$j]="NO";
  363.         }
  364.         if($ta_openaccs==null){
  365.             $ta_openaccs[0]="NO";
  366.             $ta_openaccs[1]="YES";
  367.         }
  368.         $i=0;
  369.         $tab_qrtle=null;
  370.         $qrtl1=$request->get('q1');
  371.         if($qrtl1=="Quartile 1"){
  372.             $tab_qrtle[$i]="Quartile 1";
  373.             $i=$i+1;
  374.         }
  375.         $qrtl2=$request->get('q2');
  376.         if($qrtl2=="Quartile 2"){
  377.             $tab_qrtle[$i]="Quartile 2";
  378.             $i=$i+1;
  379.         }
  380.         $qrtl3=$request->get('q3');
  381.         if($qrtl3=="Quartile 3"){
  382.             $tab_qrtle[$i]="Quartile 3";
  383.             $i=$i+1;
  384.         }
  385.         $qrtl4=$request->get('q4');
  386.         if($qrtl4=="Quartile 4"){
  387.             $tab_qrtle[$i]="Quartile 4";
  388.         }
  389.         if( $tab_qrtle==null){
  390.             $tab_qrtle[0]="Quartile 1";
  391.             $tab_qrtle[1]="Quartile 2";
  392.             $tab_qrtle[2]="Quartile 3";
  393.             $tab_qrtle[3]="Quartile 4";
  394.         }
  395.         $operation="op1";
  396.         if($request->get('sjr_r')=="option1")
  397.         {
  398.             $sjr_value=$request->get('sjr_sup');
  399.             $sjr_value=str_replace("."","$sjr_value);
  400.             $operation="op1";
  401.         }
  402.         elseif($request->get('sjr_r')=="option2"){
  403.             $sjr_value=$request->get('sjr_inf');
  404.             $sjr_value=str_replace("."","$sjr_value);
  405.             $operation="op2";
  406.         }
  407.         else {$sjr_value=0;
  408.             $operation="op1";
  409.         }
  410.         if($publisher=="All" && $subject_area=="All"){
  411.             $data_t_advanced_scopus=$em->selectForAdvancesearchWithoutSubjectAndPublisher($emS$tab_qrtle$ta_openaccs$sjr_value$operation);
  412.         }
  413.         elseif ($publisher!="All" && $subject_area=="All")
  414.         {
  415.             $data_t_advanced_scopus=$em->selectForAdvancesearchWithoutSubjectarea($em,$publisher$tab_qrtle$ta_openaccs$sjr_value$operation);
  416.         }
  417.         elseif ($publisher=="All" && $subject_area!="All")
  418.         {
  419.             $data_t_advanced_scopus=$em->selectForAdvancesearchWithoutPublisher($em,$subject_area$tab_qrtle$ta_openaccs$sjr_value$operation);
  420.         }
  421.         elseif($request->get('sjr_r')=="option1" && $request->get('sjr_sup')!="" ){
  422.             $sjr_value=$request->get('sjr_sup');
  423.             $data_t_advanced_scopus=$em->selectForAdvancesearch($emS,$publisher$subject_area$tab_qrtle ,$ta_openaccs$sjr_value$operation);
  424.         }elseif($request->get('sjr_r')=="option2" && $request->get('sjr_inf')!="" ){
  425.             $sjr_value=$request->get('sjr_inf');
  426.             $data_t_advanced_scopus=$em->selectForAdvancesearchSJRInf($emS,$publisher$subject_area$tab_qrtle ,$ta_openaccs$sjr_value);
  427.         }
  428.         if($request->get('jcr_r')=="option1" || $request->get('jcr_r')=="option2")
  429.         {
  430.             $journal_inst=null;
  431.             $i=0;
  432.             foreach ($data_t_advanced_scopus as $journal){
  433.                 $eISSNTP="";
  434.                 $eISSNTE="";
  435.                 if ($journal->getPrintISSN() != null){ $eISSNTP $journal->getPrintISSN();
  436.                     $eISSNTP substr_replace($eISSNTP"-"40);
  437.                     $journal_inst $em2->findInThomsonByIssn($eISSNTP$emS);
  438.                 }
  439.                 if ($journal_inst == null) {
  440.                     if ($journal->getEISSN() != null$eISSNTE $journal->getEISSN();
  441.                     $eISSNTE substr_replace($eISSNTE"-"40);
  442.                     $journal_inst $em2->findInThomsonByIssn($eISSNTE$emS);
  443.                 }
  444.                 if ($journal_inst != null) {
  445.                     if ($request->get('jcr_r') == "option1"){
  446.                         $jcr_value=$request->get('jcr_sup');
  447.                         $jcr_value=str_replace(",""."$jcr_value);
  448.                         if ($journal_inst->getJournalimpactfactor() != null && $journal_inst->getJournalimpactfactor() >= $jcr_value) {
  449.                             $data_intermediate[$i] = $journal;
  450.                             $i $i 1;
  451.                         }
  452.                     }
  453.                     elseif ($request->get('jcr_r') == "option2"){
  454.                         $jcr_value=$request->get('jcr_inf');
  455.                         $jcr_value=str_replace(",""."$jcr_value);
  456.                         if ($journal_inst->getJournalimpactfactor() != null && $journal_inst->getJournalimpactfactor() <= $jcr_value || $journal_inst->getJournalimpactfactor() =="Not Available" ) {
  457.                             $data_intermediate[$i] = $journal;
  458.                             $i $i 1;
  459.                         }
  460.                     }
  461.                 }
  462.             }
  463.         }
  464.         if($data_intermediate!=null)$data_t_advanced_scopus=$data_intermediate;
  465.         $pagination=0;
  466.         if(!is_null($data_t_advanced_scopus) && is_iterable($data_t_advanced_scopus)){
  467.             $pagination $this->paginator->paginate(
  468.                 $data_t_advanced_scopus/* query NOT result */
  469.                 $request->query->getInt('page'1), /*page number*/
  470.                 /*limit per page*/
  471.             );
  472.         }
  473.         return $this->render('default/searchV.html.twig', [
  474.             'data_reuter_advanced' => $data_advanced_reuters,
  475.             'data_t_scopus_advanced' => $data_t_advanced_scopus,
  476.             'data_reuter' => $data_reuters,
  477.             'data_t_scopus' => $data_t_scopus,
  478.             'listcategories'=>$categories,
  479.             'listpublishers'=>$publishers,
  480.             'pagination'=>$pagination,
  481.             'show_ad'=>$show_advanced
  482.         ]);
  483.     }
  484.     /**
  485.      * Lists all data_t_scopus entities for one publisher or subject area or quartlle.
  486.      *
  487.      * @Route("/search_journal_query", name="search_journals_for_scopus")
  488.      */
  489.     public function search_journal_for(Request $request)
  490.     {
  491.         return $this->redirectToRoute('journalSearch');
  492.     }
  493. //
  494.     /**
  495.      * Search journals by scope hints.
  496.      *
  497.      * @Route("/search-abstract/scope", name="search_by_scope_hints")
  498.      */
  499.     public function searchByScopeHints(Request $requestJournalRepository $journalRepository,EntityManagerInterface $em)
  500.     {
  501.         $hints $request->query->get('hints''');
  502.         $hintWords preg_split('/\s+/'$hints, -1PREG_SPLIT_NO_EMPTY);
  503.         $journals $em->getRepository(Journal::class)->searchByScopeHints($hintWords);
  504.         return $this->render('search/Abstract-results.html.twig', ['journals' => $journals]);
  505.     }
  506.     /**
  507.      * Show the search page.
  508.      *
  509.      * @Route("/search-abstract", name="search_page")
  510.      */
  511.     public function searchPage()
  512.     {
  513.         return $this->render('search/AbstractSearch.html.twig');
  514.     }
  515.     /**
  516.      * Lists all advancedSearchResults
  517.      *
  518.      * @Route("/advancedSearchResults", name="advancedSearchResults")
  519.      */
  520.     public function advancedSearchResults(Request $request ,EntityManagerInterface $entityManager){
  521.         $name_of_publisher=$request->get('name_of_publisher');
  522.         $subjectarea=$request->get('subjectarea');
  523.         $quartile=$request->get('quartile');
  524.         $openAccess=$request->get('openAccess');
  525.         $search="";
  526.         if($name_of_publisher && strtoupper($name_of_publisher) != "ALL"$search=$search." - Publisher : ".$name_of_publisher;
  527.         if($subjectarea && strtoupper($subjectarea) != "ALL"$search=$search." - Subject Area : ".$subjectarea;
  528.         if($quartile$search=$search." - Quartile : ".$quartile;
  529.         if($openAccess$search=$search." - OpenAccess : "$openAccess ;
  530.         $results=$entityManager->getRepository(Journal::class)->getAdvancedResults($name_of_publisher,$subjectarea,$openAccess,$quartile);
  531.         $total=$entityManager->getRepository(Journal::class)->countAdvancedSearch($name_of_publisher,$subjectarea,$openAccess,$quartile);
  532.         $page $request->get("p"1);
  533.         $perpage 10;
  534.         $journals $this->paginator->paginate($results$page$perpage);
  535.         $pages intval(ceil($total/$perpage));
  536.         return $this->render('default/searchV.html.twig', [
  537.             'results'=>$journals,
  538.             'search'=>$search,
  539.             'page' => $page,
  540.             'total'=>$total,
  541.             "pages"=>$pages,
  542.         ]);
  543.     }
  544.     ////////////////////////////////////
  545.      /**
  546.  * Lists all advancedSearchResults
  547.  *
  548.  * @Route("/Api/advancedSearchResults", name="test")
  549.  */
  550. public function advancedSearchResultsApi(Request $requestEntityManagerInterface $entityManagerSerializerInterface $serializer)
  551. {
  552.     $name_of_publisher=$request->get('name_of_publisher');
  553.         $subjectarea=$request->get('subjectarea');
  554.         $quartile=$request->get('quartile');
  555.         $openAccess=$request->get('openAccess');
  556.         $search="";
  557.         if($name_of_publisher && strtoupper($name_of_publisher) != "ALL"$search=$search." - Publisher : ".$name_of_publisher;
  558.         if($subjectarea && strtoupper($subjectarea) != "ALL"$search=$search." - Subject Area : ".$subjectarea;
  559.         if($quartile$search=$search." - Quartile : ".$quartile;
  560.         if($openAccess$search=$search." - OpenAccess : "$openAccess ;
  561.         $results $entityManager->getRepository(Journal::class)->getAdvancedResultsApi(
  562.         $name_of_publisher,
  563.         $subjectarea,
  564.         $openAccess,
  565.         $quartile
  566.     );
  567.     $jsonContent $serializer->serialize($results'json', ['groups' => 'api']);
  568.     return new JsonResponse($jsonContent200, [], true);
  569. }
  570.   /**
  571.      * Search journals by scope hints.
  572.      *
  573.      * @Route("/api/search/scope", name="search_by_scope_")
  574.      */
  575.     public function searchByScopeHintsAPi(Request $request)
  576.     {
  577.         $hints $request->query->get('hints''');
  578.         $hintWords preg_split('/\s+/'$hints, -1PREG_SPLIT_NO_EMPTY);
  579.     
  580.         $journalRepository $this->entityManager->getRepository(Journal::class);
  581.         $journals $journalRepository->searchByScopeHints($hintWords);
  582.     
  583.         $serializedJournals $this->serializer->serialize($journals'json', ['maxDepth' => 1]);    
  584.         return new JsonResponse($serializedJournals200, [], true);
  585.     }
  586.     
  587. }