src/Controller/Pages/Pages/PagesController.php line 209

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Pages\Pages;
  3. use App\Entity\Db_Seotable;
  4. use App\Entity\Db_Contents;
  5. use App\Entity\St_Settings;
  6. use App\Entity\Gl_Images;
  7. use App\Entity\Db_Users;
  8. use App\Entity\Db_Products;
  9. use App\Entity\Db_Biketypes;
  10. use Symfony\Component\Translation\TranslatorInterface;
  11. use Symfony\Component\PropertyAccess\PropertyAccess;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  15. use Symfony\Bundle\FrameworkBundle\Controller\Controller;    
  16. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  17. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  18. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Component\HttpFoundation\StreamedResponse;
  21. use Symfony\Component\Security\Core\Security;
  22. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  23.     class PagesController extends Controller
  24.     {
  25.         private $security;
  26.         
  27.         function __construct(SessionInterface $sessionSecurity $security)
  28.         {
  29.             
  30.             $this->lang         = (isset($_COOKIE['langFront']) && !empty($_COOKIE['langFront'])) ? $this->lang $_COOKIE['langFront'] : $this->lang "HU";
  31.             $this->session         $session;
  32.             $this->districts = array();
  33.             $this->security $security;
  34.         }
  35.         /**
  36.         * @Route("/teszt/teszt-oldal", name="teszt-oldal")
  37.         */
  38.         public function teszt(Security $security) {
  39.             return new Response("Teszt");
  40.         }
  41.         /**
  42.         * @Route("/sitemap.xml", defaults={"_format"="xml"}, name="sitemap")
  43.         */
  44.         public function getSitemapXml(Security $security) {
  45.             header("Expires: 0");
  46.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  47.             header("Cache-Control: no-store, no-cache, must-revalidate");
  48.             header("Cache-Control: post-check=0, pre-check=0"false);
  49.             header("Pragma: no-cache");
  50.             header("X-Robots-Tag: index, follow"true);
  51.             $contents $this->getDoctrine()->getRepository(Db_Contents::class)->findAllSitemap();
  52.             return $this->render("templates/default/pages/sitemap.html.twig", array(
  53.                 "contents" => $contents,
  54.             ));
  55.         }
  56.         /**
  57.         * @Route("/kereses", name="pages-search")
  58.         */
  59.         public function getSearchPage(Security $securityRequest $request) {
  60.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  61.             header("Expires: 0");
  62.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  63.             header("Cache-Control: no-store, no-cache, must-revalidate");
  64.             header("Cache-Control: post-check=0, pre-check=0"false);
  65.             header("Pragma: no-cache");
  66.             
  67.             return $this->redirect("/kereses/".$request->query->get("search")."/oldal/1");
  68.         }
  69.         
  70.         /**
  71.         * @Route("/kereses/blog", name="pages-search-blog")
  72.         */
  73.         public function getSearchPageBlog(Security $securityRequest $request) {
  74.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  75.             header("Expires: 0");
  76.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  77.             header("Cache-Control: no-store, no-cache, must-revalidate");
  78.             header("Cache-Control: post-check=0, pre-check=0"false);
  79.             header("Pragma: no-cache");
  80.             
  81.             return $this->redirect("/kereses/blog/".$request->query->get("search")."/oldal/1");
  82.         }
  83.          /**
  84.         * @Route("/megrendeles", name="order-success-page")asd
  85.         */
  86.         public function orderSuccessPage(Security $securityRequest $request) {
  87.             if ( $this->security->getUser() ) {
  88.                 $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]);
  89.             } else {
  90.                 $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
  91.             }
  92.             if ( $request->query->get("text") ) {
  93.                 $html $request->query->get("text");
  94.             } else {
  95.                 
  96.                 $html "";
  97.             }
  98.             $content = new Db_Contents();
  99.             $content->setTitle("Rendelés visszaigazolása");
  100.             return $this->render("templates/default/pages/order-success.html.twig", array(
  101.                 "html" => $html,
  102.                 "pages" => $pages,
  103.                 "content" => $content,
  104.             ));
  105.         }
  106.         /**
  107.         * @Route("/kezdolap", name="index")
  108.         */
  109.         public function getIndexRedirectPage(Security $security) {
  110.             header("HTTP/1.1 301 Moved Permanently"); 
  111.             header("Location: /"); 
  112.             exit();
  113.         }
  114.         /**
  115.         * @Route("/adwords", name="adwords")
  116.         */
  117.         public function getAdwirdsRedirectPage(Security $security) {
  118.             header("HTTP/1.1 301 Moved Permanently"); 
  119.             header("Location: /weboldal-keszites"); 
  120.             exit();
  121.         }
  122.         /**
  123.         * @Route("/", name="pages")
  124.         */
  125.         public function getIndexPage(Security $security) {
  126.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  127.             header("Expires: 0");
  128.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  129.             header("Cache-Control: no-store, no-cache, must-revalidate");
  130.             header("Cache-Control: post-check=0, pre-check=0"false);
  131.             header("Pragma: no-cache");
  132.             header("X-Robots-Tag: index, follow"true);
  133.             $content $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "kezdolap"]);
  134.             if ( $this->security->getUser() ) {
  135.                 $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]);
  136.             } else {
  137.                 $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
  138.             }
  139.             return $this->render("templates/default/pages/index.html.twig", array(
  140.                 "content" => $content,
  141.                 "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  142.                 "books" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 9"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"],3),
  143.                 "writes" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 11"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  144.                 "testimonials" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 10"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"],4),
  145.                 "sliders" => $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['TypeID' => 1"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  146.                 "posts" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3"Visible" => "y""Lang" => $this->lang],["ID" => "DESC"],3),
  147.                 "pages" => $pages,
  148.             ));
  149.         }
  150.         /**
  151.         * @Route("/{urlName}", name="pages-per-url-name")
  152.         */
  153.         public function getPagePerUrlName(Security $security$urlName) {
  154.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  155.             header("Expires: 0");
  156.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  157.             header("Cache-Control: no-store, no-cache, must-revalidate");
  158.             header("Cache-Control: post-check=0, pre-check=0"false);
  159.             header("Pragma: no-cache");
  160.             header("X-Robots-Tag: index, follow"true);
  161.             
  162.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
  163.             if ( $content->getOnlyWithLogin() == "y" ) {
  164.                 if ( !$security->getUser() ) {
  165.                     $product $this->getDoctrine()->getRepository(Db_Products::class)->findOneBy(["UrlName" => "eves-elofizetes"]);
  166.                     return $this->render('templates/default/pages/loggedin.html.twig', array(
  167.                         "content" => $content,
  168.                         "pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  169.                         "product" => $product,
  170.                     ));
  171.                 }
  172.             }
  173.             
  174.             if ( !$content ) {
  175.                 throw $this->createNotFoundException('The page does not exist');
  176.             }
  177.             
  178.             if ( isset($content) && !empty($content) ) {
  179.                 if ( $content->getUrlName() == "elet-thassoson" ) {
  180.                     return $this->redirect("/elet-thassoson/oldal/1""301");
  181.                 }
  182.                 
  183.                 if ( file_exists($this->getParameter('template_dir')."templates/default/pages/page-".$content->getID().".html.twig") ) {
  184.                     $render "templates/default/pages/page-".$content->getID().".html.twig";
  185.                 } else {
  186.                     if (  $content->getTypeId() == ) {
  187.                         $render "templates/default/pages/page-content-books.html.twig";
  188.                     } else if ( $content->getTypeId() == ) {
  189.                         $render "templates/default/pages/page-content-blog.html.twig";
  190.                     } else {
  191.                         $render "templates/default/pages/page-content.html.twig";
  192.                     }
  193.                     
  194.                 }
  195.                 if ( $this->security->getUser() ) {
  196.                     $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]);
  197.                 } else {
  198.                     $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
  199.                 }
  200.                 return $this->render($render, array(
  201.                     "content"             => $content,
  202.                 "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  203.                 "books" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 9"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"],3),
  204.                 "writes" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 11"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  205.                 "testimonials" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 10"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"],4),
  206.                 "sliders" => $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['TypeID' => 1"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  207.                 "posts" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3"Visible" => "y""Lang" => $this->lang],["ID" => "DESC"],3),
  208.                 "pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  209.                 "subcontents" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y""ParentID" => $content->getId()],["Short" => "ASC"]),
  210.                 ));
  211.             } else {
  212.                 return $this->render('templates/default/pages/404.html.twig', array(
  213.                     "content" => $content,
  214.                     "pages"    => $pages,
  215.                 ));
  216.             }
  217.         }
  218.         /**
  219.         * @Route("/{urlName}/oldal/{pageNumber}", name="pages-per-url-name-per-page")
  220.         */
  221.         public function getPagePerUrlNamePerPage(Security $security$urlName$pageNumberRequest $request) {
  222.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  223.             header("Expires: 0");
  224.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  225.             header("Cache-Control: no-store, no-cache, must-revalidate");
  226.             header("Cache-Control: post-check=0, pre-check=0"false);
  227.             header("Pragma: no-cache");
  228.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
  229.             if ( !$content ) {
  230.                 throw $this->createNotFoundException('The page does not exist');
  231.             }
  232.             if ( isset($content) && !empty($content) ) {
  233.                 
  234.                 if ( file_exists($this->getParameter('template_dir')."templates/default/pages/page-".$content->getID().".html.twig") ) {
  235.                     $render "templates/default/pages/page-".$content->getID().".html.twig";
  236.                 } else {
  237.                     $render "templates/default/pages/page-content.html.twig";
  238.                 }
  239.                 $perPage 10;
  240.                 if ( $pageNumber != ) {
  241.                     $xPage      = (($pageNumber-1)*$perPage);
  242.                 } else {
  243.                     $xPage      0;
  244.                 }
  245.                 return $this->render($render, array(
  246.                     "content"             => $content,
  247.                     "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  248.                     "books" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 9"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"],3),
  249.                     "writes" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 11"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  250.                     "testimonials" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 10"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"],4),
  251.                     "sliders" => $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['TypeID' => 1"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  252.                     "blogs"    => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3"Visible" => "y""Lang" => $this->lang],["ID" => "DESC"], $perPage$xPage),
  253.                     "pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  254.                     "subcontents" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y""ParentID" => $content->getId()],["Short" => "ASC"]),
  255.                     "actualPage" => $pageNumber,
  256.                 ));
  257.             } else {
  258.                 return $this->render('templates/default/pages/404.html.twig', array(
  259.                     "content" => $content,
  260.                     "pages"    => $pages,
  261.                 ));
  262.             }
  263.         }
  264.         /**
  265.         * @Route("/cimkek/{urlName}/oldal/{pageNumber}", name="pages-tags")
  266.         */
  267.         public function getTagsElement(Security $security$urlName$pageNumberRequest $request) {
  268.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  269.             header("Expires: 0");
  270.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  271.             header("Cache-Control: no-store, no-cache, must-revalidate");
  272.             header("Cache-Control: post-check=0, pre-check=0"false);
  273.             header("Pragma: no-cache");
  274.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "tudastar"]);
  275.             $tag $this->getDoctrine()->getRepository(Db_Biketypes::class)->findOneBy(["UrlName" => $urlName]);
  276.             if ( !$content ) {
  277.                 throw $this->createNotFoundException('The page does not exist');
  278.             }
  279.             if ( isset($content) && !empty($content) ) {
  280.                 
  281.                 $render "templates/default/pages/page-tags.html.twig";
  282.                 $fullPage count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByTagsAll($tag->getNameHU()));
  283.                 return $this->render($render, array(
  284.                     "content"             => $content,
  285.                     "pages"    => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  286.                     "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  287.                     "bases" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByTags($tag->getNameHU(), $pageNumber),
  288.                     "tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
  289.                     "actualPage" => $pageNumber,
  290.                     "tag" => $tag,
  291.                     "fullPage" => ceil($fullPage/10),
  292.                 ));
  293.             } else {
  294.                 return $this->render('templates/default/pages/404.html.twig', array(
  295.                     "content" => $content,
  296.                     "pages"    => $pages,
  297.                 ));
  298.             }
  299.         }
  300.         /**
  301.         * @Route("/kulcsszo/{urlName}/oldal/{pageNumber}", name="pages-keyword")
  302.         */
  303.         public function getKeywordElement(Security $security$urlName$pageNumberRequest $request) {
  304.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  305.             header("Expires: 0");
  306.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  307.             header("Cache-Control: no-store, no-cache, must-revalidate");
  308.             header("Cache-Control: post-check=0, pre-check=0"false);
  309.             header("Pragma: no-cache");
  310.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "tudastar"]);
  311.             
  312.             if ( !$content ) {
  313.                 throw $this->createNotFoundException('The page does not exist');
  314.             }
  315.             if ( isset($content) && !empty($content) ) {
  316.                 
  317.                 $render "templates/default/pages/page-keywords.html.twig";
  318.                 $fullPage count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByKeywordAll($urlName));
  319.                 return $this->render($render, array(
  320.                     "content"             => $content,
  321.                     "pages"    => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  322.                     "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  323.                     "bases" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByKeyword($urlName$pageNumber),
  324.                     "tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
  325.                     "actualPage" => $pageNumber,
  326.                     "tag" => array("UrlName" => $urlName),
  327.                     "fullPage" => ceil($fullPage/10),
  328.                 ));
  329.             } else {
  330.                 return $this->render('templates/default/pages/404.html.twig', array(
  331.                     "content" => $content,
  332.                     "pages"    => $pages,
  333.                 ));
  334.             }
  335.         }
  336.         /**
  337.         * @Route("/kereses/{urlName}/oldal/{pageNumber}", name="pages-keyword-per-page")
  338.         */
  339.         public function getSearchPagePerPage(Security $security$urlName$pageNumberRequest $request) {
  340.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  341.             header("Expires: 0");
  342.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  343.             header("Cache-Control: no-store, no-cache, must-revalidate");
  344.             header("Cache-Control: post-check=0, pre-check=0"false);
  345.             header("Pragma: no-cache");
  346.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "tudastar"]);
  347.             
  348.             if ( !$content ) {
  349.                 throw $this->createNotFoundException('The page does not exist');
  350.             }
  351.             if ( isset($content) && !empty($content) ) {
  352.                 
  353.                 $render "templates/default/pages/page-search.html.twig";
  354.                 $fullPage count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryBySearchAll($urlName));
  355.                 return $this->render($render, array(
  356.                     "content"             => $content,
  357.                     "pages"    => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  358.                     "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  359.                     "bases" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryBySearch($urlName$pageNumber),
  360.                     "tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
  361.                     "actualPage" => $pageNumber,
  362.                     "tag" => array("UrlName" => $urlName),
  363.                     "fullPage" => ceil($fullPage/10),
  364.                 ));
  365.             } else {
  366.                 return $this->render('templates/default/pages/404.html.twig', array(
  367.                     "content" => $content,
  368.                     "pages"    => $pages,
  369.                 ));
  370.             }
  371.         }
  372.         /**
  373.         * @Route("/kereses/blog/{urlName}/oldal/{pageNumber}", name="pages-keyword-per-page-blog")
  374.         */
  375.         public function getSearchPagePerPageBlog(Security $security$urlName$pageNumberRequest $request) {
  376.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  377.             header("Expires: 0");
  378.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  379.             header("Cache-Control: no-store, no-cache, must-revalidate");
  380.             header("Cache-Control: post-check=0, pre-check=0"false);
  381.             header("Pragma: no-cache");
  382.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "blog"]);
  383.             
  384.             if ( !$content ) {
  385.                 throw $this->createNotFoundException('The page does not exist');
  386.             }
  387.             if ( isset($content) && !empty($content) ) {
  388.                 
  389.                 $render "templates/default/pages/page-search-blog.html.twig";
  390.                 $fullPage count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogBySearchAll($urlName));
  391.                 if ( $this->security->getUser() ) {
  392.                     $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]);
  393.                 } else {
  394.                     $pages =  $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
  395.                 }
  396.                 return $this->render($render, array(
  397.                     "content"             => $content,
  398.                     "pages" => $pages,
  399.                     "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  400.                     "blogs" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogBySearchAllByPage($urlName$pageNumber),
  401.                     "tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
  402.                     "actualPage" => $pageNumber,
  403.                     "urlName" => $urlName,
  404.                     "fullPage" => ceil($fullPage/10),
  405.                     "postCategories" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 14"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  406.                 ));
  407.             } else {
  408.                 return $this->render('templates/default/pages/404.html.twig', array(
  409.                     "content" => $content,
  410.                     "pages"    => $pages,
  411.                 ));
  412.             }
  413.         }
  414.         /**
  415.         * @Route("/cikk-kategoria/{urlName}/oldal/{pageNumber}", name="pages-category-per-page-blog")
  416.         */
  417.         public function getCategoryPagePerPageBlog(Security $security$urlName$pageNumberRequest $request) {
  418.             //Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
  419.             header("Expires: 0");
  420.             header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  421.             header("Cache-Control: no-store, no-cache, must-revalidate");
  422.             header("Cache-Control: post-check=0, pre-check=0"false);
  423.             header("Pragma: no-cache");
  424.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "blog"]);
  425.             
  426.             if ( !$content ) {
  427.                 throw $this->createNotFoundException('The page does not exist');
  428.             }
  429.             if ( isset($content) && !empty($content) ) {
  430.                 $searchContent $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
  431.                 $render "templates/default/pages/page-keyword-blog.html.twig";
  432.                 $fullPage count($this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3"Visible" => "y""Lang" => $this->lang"ParentID" => $searchContent->getId()],["Short" => "DESC"]));
  433.                 $perPage 10;
  434.                 if ( $pageNumber != ) {
  435.                     $xPage      = (($pageNumber-1)*$perPage);
  436.                 } else {
  437.                     $xPage      0;
  438.                 }
  439.                 
  440.                 return $this->render($render, array(
  441.                     "content"             => $content,
  442.                     "pages"    => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7"Visible" => "y""ParentID" => [""NULL]],["Short" => "ASC"]),
  443.                     "seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
  444.                     "blogs" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3"Visible" => "y""Lang" => $this->lang"ParentID" => $searchContent->getId()],["Short" => "DESC"], $perPage$xPage),
  445.                     "tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
  446.                     "actualPage" => $pageNumber,
  447.                     "urlName" => $urlName,
  448.                     "fullPage" => ceil($fullPage/10),
  449.                     "postCategories" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 14"Visible" => "y""Lang" => $this->lang],["Short" => "DESC"]),
  450.                 ));
  451.             } else {
  452.                 return $this->render('templates/default/pages/404.html.twig', array(
  453.                     "content" => $content,
  454.                     "pages"    => $pages,
  455.                 ));
  456.             }
  457.         }
  458.         /**
  459.         * @Route("/{asd}/{fgh}", name="pages-a-b")
  460.         */
  461.         public function Atiranyitaszvegrehogymehessekhaza(Security $security$asd$fghRequest $request) {
  462.             return $this->redirect("/"301);
  463.         }
  464.         /**
  465.         * @Route("/{y}/{m}/{d}/{urlName}", name="pages-old-blog")
  466.         */
  467.         public function getOldBlog(Security $security$urlNameRequest $request) {
  468.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
  469.             if ( !$content ) {
  470.                 return $this->redirect("/"301);
  471.             } else {
  472.                 header("Expires: 0");
  473.                 header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  474.                 header("Cache-Control: no-store, no-cache, must-revalidate");
  475.                 header("Cache-Control: post-check=0, pre-check=0"false);
  476.                 header("Pragma: no-cache");
  477.                 
  478.                 return $this->redirect("/".$urlName);
  479.             }
  480.         }
  481.         /**
  482.         * @Route("/{y}/{m}/{d}/{urlName}/feed", name="pages-old-blog-feed")
  483.         */
  484.         public function getOldBlogFeed(Security $security$urlNameRequest $request) {
  485.             $content     $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
  486.             if ( !$content ) {
  487.                 return $this->redirect("/"301);
  488.             } else {
  489.                 header("Expires: 0");
  490.                 header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  491.                 header("Cache-Control: no-store, no-cache, must-revalidate");
  492.                 header("Cache-Control: post-check=0, pre-check=0"false);
  493.                 header("Pragma: no-cache");
  494.                 
  495.                 return $this->redirect("/".$urlName);
  496.             }
  497.         }
  498.        
  499.         public function getMenuSubsByID($id) {
  500.             //Lekérdezzük a "Főmenühöz" tartozó aloldalakat.
  501.             if ( $this->security->getUser() ) {
  502.                 $pages     $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y""ParentID" => $id]);
  503.             } else {
  504.                 $pages     $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y""ParentID" => $id"OnlyWithLogin" => "n"]);
  505.             }
  506.             
  507.             //Amennyiben találunk aloldalt a szülőhöz továbblépünk a html generáláshoz.
  508.             if ( isset($pages) && !empty($pages) ) {
  509.                 //A $html változó elkészítése és alap értékének beállítása.
  510.                 $html     '<ul>'
  511.                 //Végigjárjuk a visszakapott aloldalakat.
  512.                 foreach ( $pages as $page ) {
  513.                     
  514.                     if ( $this->lang == "HU" ) {
  515.                         $pageName $page->getTitle();
  516.                     } elseif ($this->lang == "EN") {
  517.                         $pageName $page->getTitleEN();
  518.                     } else {
  519.                         $pageName $page->getTitle();
  520.                     }
  521.                     //Minden aloldalhoz legeneráljuk a megfelelő html sort.
  522.                     
  523.                     $subPages     $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y""ParentID" => $page->getID()]);
  524.                     if ( $subPages ) {
  525.                         if ( $page->getOnlyWithLogin() == "y" ) {
  526.                             if ( $this->security->getUser() ) {
  527.                                 $html .= '<li class="dropdown"><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
  528.                             } else {
  529.                                 $html .= '<li class="dropdown">';
  530.                             }
  531.                         } else {
  532.                             $html .= '<li class="dropdown"><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
  533.                         }
  534.                         
  535.                     } else {
  536.                         if ( $page->getOnlyWithLogin() == "y" ) {
  537.                             if ( $this->security->getUser() ) {
  538.                                 $html .= '<li><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
  539.                             } else {
  540.                                 $html .= '';
  541.                             }
  542.                         } else {
  543.                             $html .= '<li><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
  544.                         }
  545.                         
  546.                     }
  547.                     
  548.                     //Visszatérünk a funkcióba az aloldal ID értékével. Erre azért van szükség, hogy lefusson a funkció az almenüpont almenüire is.
  549.                     //Ez a művelet ismétlődik egészen addig, amíg el nem fogynak az aloldalak aloldalai.
  550.                     $subMenus $this->getMenuSubsByID($page->getID());
  551.                     //A legenerált html kódot átadjuk egy változóba.
  552.                     //Ha a változó nem üres akkor a $subMenu objektum getContent változóját lekérjük. Csak erre az egy értékre van szükségünk.
  553.                     if ( isset($subMenus) && !empty($subMenus) ) {
  554.                         //A $html változóhoz hozzáadjuk a $subMenu->getContent() értékét. Ez az érték önmagában egy html kódot tartalmaz az eddigiek alapján.
  555.                         $html .= $subMenus->getContent();
  556.                     } else {
  557.                         //Amennyiben üres a $subMenu változó lezárjuk az előző generált listát.
  558.                         $html .= "</li>";
  559.                     }
  560.                     
  561.                 }    
  562.                 //Lezárjuk a megnyitott ul-t.
  563.                 $html .= '</ul>';
  564.             } else {
  565.                 //Amennyiben egyáltalán nicns aloldala a főmenünek a generált $html változó üres.
  566.                 $html "";
  567.             }
  568.             //Visszatérünk a teljesen legenerált $html változóval, majd kiíratjuk a menübe.
  569.             return new Response($html);
  570.             
  571.         }
  572.         /**
  573.         * @Route("/cookies/set-pagination-cookie", name="set-pagination-cookie")
  574.         */
  575.         public function setPaginationCookie(Request $requestAuthenticationUtils $authenticationUtilsSecurity $security)
  576.         {
  577.             if ( isset($_POST) && !empty($_POST) ) {
  578.                 setcookie("paginationCookie"$_POST['pageCount'], time() + (86400 30), "/"); 
  579.             }
  580.             die();
  581.             
  582.         }
  583.         /**
  584.         * @Route("/cookies/start-user-cookie", name="cookies-start-user-cookie")
  585.         */
  586.         public function startUserCookie(Request $requestAuthenticationUtils $authenticationUtilsSecurity $security)
  587.         {
  588.             
  589.             if ( isset($_COOKIE['orderCookieId']) && !empty($_COOKIE['orderCookieId']) ) {
  590.                 $cookieID $_COOKIE['orderCookieId'];
  591.                 
  592.             } else {
  593.                 $cookieID rand(099999).md5(uniqid());
  594.                 
  595.             }
  596.             setcookie("orderCookieId"$cookieIDtime() + (86400 30) * 30"/");
  597.             return new Response($cookieID);
  598.             
  599.         }
  600.         
  601.         public function getSettingsByID(Request $requestAuthenticationUtils $authenticationUtilsSecurity $security$id)
  602.         {
  603.             
  604.             $settings $this->getDoctrine()->getRepository(St_Settings::class)->find($id);
  605.             return new Response($settings->getSettingsValue());
  606.             
  607.         }
  608.         public function getPagesByContentTypeID(Request $requestAuthenticationUtils $authenticationUtilsSecurity $security$id)
  609.         {
  610.             
  611.             $perpage 10;
  612.             $contents count($this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["TypeID" => $id]));
  613.             return new Response(ceil($contents/$perpage));
  614.             
  615.         }
  616.         
  617.         public function getContentBySubcontent(Request $requestAuthenticationUtils $authenticationUtilsSecurity $security$id)
  618.         {
  619.             
  620.             $content $this->getDoctrine()->getRepository(Db_Contents::class)->find($id);
  621.             $array = array();
  622.             if ( $content ) {
  623.                 $array = array(
  624.                     "name" => $content->getTitle(),
  625.                     "urlName" => $content->getUrlName(),
  626.                 );
  627.             }
  628.             
  629.             return new Response(json_encode($array));
  630.             
  631.         }
  632.         public function getAllContentByKeywords(Request $requestAuthenticationUtils $authenticationUtilsSecurity $security$id)
  633.         {
  634.             
  635.             $contents $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryBySearchAllByPage($id);
  636.             $array = array();
  637.             $i 0;
  638.             foreach($contents as $content) {
  639.                 if ( $content ) {
  640.                     $array[$i] = array(
  641.                         "name" => $content->getTitle(),
  642.                         "urlName" => $content->getUrlName(),
  643.                         "content" => $content->getShortText(),
  644.                     );
  645.                     $i++;
  646.                 }
  647.                 
  648.             }
  649.             
  650.             return new Response(json_encode($array));
  651.             
  652.         }
  653.         private function StrReplaceKeywrods($search$replace$subject)
  654.         {
  655.             $search '/\b'.preg_quote($search'/').'\b/';
  656.             return preg_replace($search$replace$subject1);
  657.         }
  658.     }