<?php
namespace App\Controller\Pages\Pages;
use App\Entity\Db_Seotable;
use App\Entity\Db_Contents;
use App\Entity\St_Settings;
use App\Entity\Gl_Images;
use App\Entity\Db_Users;
use App\Entity\Db_Products;
use App\Entity\Db_Biketypes;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class PagesController extends Controller
{
private $security;
function __construct(SessionInterface $session, Security $security)
{
$this->lang = (isset($_COOKIE['langFront']) && !empty($_COOKIE['langFront'])) ? $this->lang = $_COOKIE['langFront'] : $this->lang = "HU";
$this->session = $session;
$this->districts = array();
$this->security = $security;
}
/**
* @Route("/teszt/teszt-oldal", name="teszt-oldal")
*/
public function teszt(Security $security) {
return new Response("Teszt");
}
/**
* @Route("/sitemap.xml", defaults={"_format"="xml"}, name="sitemap")
*/
public function getSitemapXml(Security $security) {
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("X-Robots-Tag: index, follow", true);
$contents = $this->getDoctrine()->getRepository(Db_Contents::class)->findAllSitemap();
return $this->render("templates/default/pages/sitemap.html.twig", array(
"contents" => $contents,
));
}
/**
* @Route("/kereses", name="pages-search")
*/
public function getSearchPage(Security $security, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
return $this->redirect("/kereses/".$request->query->get("search")."/oldal/1");
}
/**
* @Route("/kereses/blog", name="pages-search-blog")
*/
public function getSearchPageBlog(Security $security, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
return $this->redirect("/kereses/blog/".$request->query->get("search")."/oldal/1");
}
/**
* @Route("/megrendeles", name="order-success-page")asd
*/
public function orderSuccessPage(Security $security, Request $request) {
if ( $this->security->getUser() ) {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]);
} else {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
}
if ( $request->query->get("text") ) {
$html = $request->query->get("text");
} else {
$html = "";
}
$content = new Db_Contents();
$content->setTitle("Rendelés visszaigazolása");
return $this->render("templates/default/pages/order-success.html.twig", array(
"html" => $html,
"pages" => $pages,
"content" => $content,
));
}
/**
* @Route("/kezdolap", name="index")
*/
public function getIndexRedirectPage(Security $security) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /");
exit();
}
/**
* @Route("/adwords", name="adwords")
*/
public function getAdwirdsRedirectPage(Security $security) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /weboldal-keszites");
exit();
}
/**
* @Route("/", name="pages")
*/
public function getIndexPage(Security $security) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("X-Robots-Tag: index, follow", true);
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "kezdolap"]);
if ( $this->security->getUser() ) {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]);
} else {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
}
return $this->render("templates/default/pages/index.html.twig", array(
"content" => $content,
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"books" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 9, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"],3),
"writes" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 11, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
"testimonials" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 10, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"],4),
"sliders" => $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['TypeID' => 1, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
"posts" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3, "Visible" => "y", "Lang" => $this->lang],["ID" => "DESC"],3),
"pages" => $pages,
));
}
/**
* @Route("/{urlName}", name="pages-per-url-name")
*/
public function getPagePerUrlName(Security $security, $urlName) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("X-Robots-Tag: index, follow", true);
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
if ( $content->getOnlyWithLogin() == "y" ) {
if ( !$security->getUser() ) {
$product = $this->getDoctrine()->getRepository(Db_Products::class)->findOneBy(["UrlName" => "eves-elofizetes"]);
return $this->render('templates/default/pages/loggedin.html.twig', array(
"content" => $content,
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"product" => $product,
));
}
}
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
if ( $content->getUrlName() == "elet-thassoson" ) {
return $this->redirect("/elet-thassoson/oldal/1", "301");
}
if ( file_exists($this->getParameter('template_dir')."templates/default/pages/page-".$content->getID().".html.twig") ) {
$render = "templates/default/pages/page-".$content->getID().".html.twig";
} else {
if ( $content->getTypeId() == 9 ) {
$render = "templates/default/pages/page-content-books.html.twig";
} else if ( $content->getTypeId() == 3 ) {
$render = "templates/default/pages/page-content-blog.html.twig";
} else {
$render = "templates/default/pages/page-content.html.twig";
}
}
if ( $this->security->getUser() ) {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]);
} else {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
}
return $this->render($render, array(
"content" => $content,
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"books" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 9, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"],3),
"writes" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 11, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
"testimonials" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 10, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"],4),
"sliders" => $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['TypeID' => 1, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
"posts" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3, "Visible" => "y", "Lang" => $this->lang],["ID" => "DESC"],3),
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"subcontents" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y", "ParentID" => $content->getId()],["Short" => "ASC"]),
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/{urlName}/oldal/{pageNumber}", name="pages-per-url-name-per-page")
*/
public function getPagePerUrlNamePerPage(Security $security, $urlName, $pageNumber, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
if ( file_exists($this->getParameter('template_dir')."templates/default/pages/page-".$content->getID().".html.twig") ) {
$render = "templates/default/pages/page-".$content->getID().".html.twig";
} else {
$render = "templates/default/pages/page-content.html.twig";
}
$perPage = 10;
if ( $pageNumber != 1 ) {
$xPage = (($pageNumber-1)*$perPage);
} else {
$xPage = 0;
}
return $this->render($render, array(
"content" => $content,
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"books" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 9, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"],3),
"writes" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 11, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
"testimonials" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 10, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"],4),
"sliders" => $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['TypeID' => 1, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
"blogs" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3, "Visible" => "y", "Lang" => $this->lang],["ID" => "DESC"], $perPage, $xPage),
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"subcontents" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y", "ParentID" => $content->getId()],["Short" => "ASC"]),
"actualPage" => $pageNumber,
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/cimkek/{urlName}/oldal/{pageNumber}", name="pages-tags")
*/
public function getTagsElement(Security $security, $urlName, $pageNumber, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "tudastar"]);
$tag = $this->getDoctrine()->getRepository(Db_Biketypes::class)->findOneBy(["UrlName" => $urlName]);
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
$render = "templates/default/pages/page-tags.html.twig";
$fullPage = count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByTagsAll($tag->getNameHU()));
return $this->render($render, array(
"content" => $content,
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"bases" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByTags($tag->getNameHU(), $pageNumber),
"tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
"actualPage" => $pageNumber,
"tag" => $tag,
"fullPage" => ceil($fullPage/10),
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/kulcsszo/{urlName}/oldal/{pageNumber}", name="pages-keyword")
*/
public function getKeywordElement(Security $security, $urlName, $pageNumber, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "tudastar"]);
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
$render = "templates/default/pages/page-keywords.html.twig";
$fullPage = count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByKeywordAll($urlName));
return $this->render($render, array(
"content" => $content,
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"bases" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryByKeyword($urlName, $pageNumber),
"tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
"actualPage" => $pageNumber,
"tag" => array("UrlName" => $urlName),
"fullPage" => ceil($fullPage/10),
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/kereses/{urlName}/oldal/{pageNumber}", name="pages-keyword-per-page")
*/
public function getSearchPagePerPage(Security $security, $urlName, $pageNumber, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "tudastar"]);
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
$render = "templates/default/pages/page-search.html.twig";
$fullPage = count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryBySearchAll($urlName));
return $this->render($render, array(
"content" => $content,
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"bases" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryBySearch($urlName, $pageNumber),
"tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
"actualPage" => $pageNumber,
"tag" => array("UrlName" => $urlName),
"fullPage" => ceil($fullPage/10),
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/kereses/blog/{urlName}/oldal/{pageNumber}", name="pages-keyword-per-page-blog")
*/
public function getSearchPagePerPageBlog(Security $security, $urlName, $pageNumber, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "blog"]);
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
$render = "templates/default/pages/page-search-blog.html.twig";
$fullPage = count($this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogBySearchAll($urlName));
if ( $this->security->getUser() ) {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]);
} else {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL], "OnlyWithLogin" => "n"],["Short" => "ASC"]);
}
return $this->render($render, array(
"content" => $content,
"pages" => $pages,
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"blogs" => $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogBySearchAllByPage($urlName, $pageNumber),
"tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
"actualPage" => $pageNumber,
"urlName" => $urlName,
"fullPage" => ceil($fullPage/10),
"postCategories" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 14, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/cikk-kategoria/{urlName}/oldal/{pageNumber}", name="pages-category-per-page-blog")
*/
public function getCategoryPagePerPageBlog(Security $security, $urlName, $pageNumber, Request $request) {
//Beállítjuk az adott oldalt header adatait, hogy ne cacheljen.
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => "blog"]);
if ( !$content ) {
throw $this->createNotFoundException('The page does not exist');
}
if ( isset($content) && !empty($content) ) {
$searchContent = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
$render = "templates/default/pages/page-keyword-blog.html.twig";
$fullPage = count($this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3, "Visible" => "y", "Lang" => $this->lang, "ParentID" => $searchContent->getId()],["Short" => "DESC"]));
$perPage = 10;
if ( $pageNumber != 1 ) {
$xPage = (($pageNumber-1)*$perPage);
} else {
$xPage = 0;
}
return $this->render($render, array(
"content" => $content,
"pages" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 7, "Visible" => "y", "ParentID" => ["", NULL]],["Short" => "ASC"]),
"seo" => $this->getDoctrine()->getRepository(Db_Seotable::class)->findSeoDataByPageIDAndType($content->getID(), "Content"),
"blogs" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 3, "Visible" => "y", "Lang" => $this->lang, "ParentID" => $searchContent->getId()],["Short" => "DESC"], $perPage, $xPage),
"tags" => $this->getDoctrine()->getRepository(Db_Biketypes::class)->findBy(['Visible' => "y"]),
"actualPage" => $pageNumber,
"urlName" => $urlName,
"fullPage" => ceil($fullPage/10),
"postCategories" => $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(['TypeID' => 14, "Visible" => "y", "Lang" => $this->lang],["Short" => "DESC"]),
));
} else {
return $this->render('templates/default/pages/404.html.twig', array(
"content" => $content,
"pages" => $pages,
));
}
}
/**
* @Route("/{asd}/{fgh}", name="pages-a-b")
*/
public function Atiranyitaszvegrehogymehessekhaza(Security $security, $asd, $fgh, Request $request) {
return $this->redirect("/", 301);
}
/**
* @Route("/{y}/{m}/{d}/{urlName}", name="pages-old-blog")
*/
public function getOldBlog(Security $security, $urlName, Request $request) {
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
if ( !$content ) {
return $this->redirect("/", 301);
} else {
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
return $this->redirect("/".$urlName);
}
}
/**
* @Route("/{y}/{m}/{d}/{urlName}/feed", name="pages-old-blog-feed")
*/
public function getOldBlogFeed(Security $security, $urlName, Request $request) {
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->findOneBy(['UrlName' => $urlName]);
if ( !$content ) {
return $this->redirect("/", 301);
} else {
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
return $this->redirect("/".$urlName);
}
}
public function getMenuSubsByID($id) {
//Lekérdezzük a "Főmenühöz" tartozó aloldalakat.
if ( $this->security->getUser() ) {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y", "ParentID" => $id]);
} else {
$pages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y", "ParentID" => $id, "OnlyWithLogin" => "n"]);
}
//Amennyiben találunk aloldalt a szülőhöz továbblépünk a html generáláshoz.
if ( isset($pages) && !empty($pages) ) {
//A $html változó elkészítése és alap értékének beállítása.
$html = '<ul>';
//Végigjárjuk a visszakapott aloldalakat.
foreach ( $pages as $page ) {
if ( $this->lang == "HU" ) {
$pageName = $page->getTitle();
} elseif ($this->lang == "EN") {
$pageName = $page->getTitleEN();
} else {
$pageName = $page->getTitle();
}
//Minden aloldalhoz legeneráljuk a megfelelő html sort.
$subPages = $this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["Visible" => "y", "ParentID" => $page->getID()]);
if ( $subPages ) {
if ( $page->getOnlyWithLogin() == "y" ) {
if ( $this->security->getUser() ) {
$html .= '<li class="dropdown"><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
} else {
$html .= '<li class="dropdown">';
}
} else {
$html .= '<li class="dropdown"><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
}
} else {
if ( $page->getOnlyWithLogin() == "y" ) {
if ( $this->security->getUser() ) {
$html .= '<li><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
} else {
$html .= '';
}
} else {
$html .= '<li><a href="/'.$page->getUrlName().'">'.$pageName.'</a>';
}
}
//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.
//Ez a művelet ismétlődik egészen addig, amíg el nem fogynak az aloldalak aloldalai.
$subMenus = $this->getMenuSubsByID($page->getID());
//A legenerált html kódot átadjuk egy változóba.
//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.
if ( isset($subMenus) && !empty($subMenus) ) {
//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.
$html .= $subMenus->getContent();
} else {
//Amennyiben üres a $subMenu változó lezárjuk az előző generált listát.
$html .= "</li>";
}
}
//Lezárjuk a megnyitott ul-t.
$html .= '</ul>';
} else {
//Amennyiben egyáltalán nicns aloldala a főmenünek a generált $html változó üres.
$html = "";
}
//Visszatérünk a teljesen legenerált $html változóval, majd kiíratjuk a menübe.
return new Response($html);
}
/**
* @Route("/cookies/set-pagination-cookie", name="set-pagination-cookie")
*/
public function setPaginationCookie(Request $request, AuthenticationUtils $authenticationUtils, Security $security)
{
if ( isset($_POST) && !empty($_POST) ) {
setcookie("paginationCookie", $_POST['pageCount'], time() + (86400 * 30), "/");
}
die();
}
/**
* @Route("/cookies/start-user-cookie", name="cookies-start-user-cookie")
*/
public function startUserCookie(Request $request, AuthenticationUtils $authenticationUtils, Security $security)
{
if ( isset($_COOKIE['orderCookieId']) && !empty($_COOKIE['orderCookieId']) ) {
$cookieID = $_COOKIE['orderCookieId'];
} else {
$cookieID = rand(0, 99999).md5(uniqid());
}
setcookie("orderCookieId", $cookieID, time() + (86400 * 30) * 30, "/");
return new Response($cookieID);
}
public function getSettingsByID(Request $request, AuthenticationUtils $authenticationUtils, Security $security, $id)
{
$settings = $this->getDoctrine()->getRepository(St_Settings::class)->find($id);
return new Response($settings->getSettingsValue());
}
public function getPagesByContentTypeID(Request $request, AuthenticationUtils $authenticationUtils, Security $security, $id)
{
$perpage = 10;
$contents = count($this->getDoctrine()->getRepository(Db_Contents::class)->findBy(["TypeID" => $id]));
return new Response(ceil($contents/$perpage));
}
public function getContentBySubcontent(Request $request, AuthenticationUtils $authenticationUtils, Security $security, $id)
{
$content = $this->getDoctrine()->getRepository(Db_Contents::class)->find($id);
$array = array();
if ( $content ) {
$array = array(
"name" => $content->getTitle(),
"urlName" => $content->getUrlName(),
);
}
return new Response(json_encode($array));
}
public function getAllContentByKeywords(Request $request, AuthenticationUtils $authenticationUtils, Security $security, $id)
{
$contents = $this->getDoctrine()->getRepository(Db_Contents::class)->findByBlogsAndCategoryBySearchAllByPage($id);
$array = array();
$i = 0;
foreach($contents as $content) {
if ( $content ) {
$array[$i] = array(
"name" => $content->getTitle(),
"urlName" => $content->getUrlName(),
"content" => $content->getShortText(),
);
$i++;
}
}
return new Response(json_encode($array));
}
private function StrReplaceKeywrods($search, $replace, $subject)
{
$search = '/\b'.preg_quote($search, '/').'\b/';
return preg_replace($search, $replace, $subject, 1);
}
}