src/Troika/RealEstateBundle/Controller/DefaultController.php line 415

Open in your IDE?
  1. <?php
  2. namespace Troika\RealEstateBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  6. use Troika\MainBundle\Command\GenerateShitFiltersCommand;
  7. class DefaultController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
  8. {
  9.     public function aboutAction()
  10.     {
  11.         $repository $this->getDoctrine()->getRepository('TroikaMainBundle:About');
  12.         $about $repository->find(1);
  13.         if (empty($about)) {
  14.             throw new NotFoundHttpException();
  15.         }
  16.         return $this->render('TroikaRealEstateBundle:About:about.html.twig', [
  17.           'title'       => $about->getTitle(),
  18.           'description' => $about->getDescription(),
  19.           'keywords'    => $about->getKeywords(),
  20.           'content1'    => $about->getContent1(),
  21.           'content2'    => $about->getContent2(),
  22.           'content3'    => $about->getContent3(),
  23.           'content4'    => $about->getContent4(),
  24.           'img1'        => $about->getWebPathImg1(),
  25.           'img2'        => $about->getWebPathImg2(),
  26.           'img3'        => $about->getWebPathImg3(),
  27.           'img4'        => $about->getWebPathImg4(),
  28.         ]);
  29.     }
  30.     public function agreementAction()
  31.     {
  32.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  33.         return $this->render('TroikaRealEstateBundle:About:agreement.html.twig',['page'=>$page]);
  34.     }
  35.     public function analyticAction()
  36.     {
  37.         $page $_GET['page'] ?? 1;
  38.         $analytics $this->container->get('analytic.model')->getPage($page);
  39.         $em $this->getDoctrine()->getEntityManager();
  40.         $connection $em->getConnection();
  41.         $statement =
  42.           $connection->prepare("select left(date,4) as date, 
  43.        count(*) from Analytic where published = 1 group by left(date,4) order by left(date,4) DESC");
  44.         $statement->execute();
  45.         $date $statement->fetchAll();
  46.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  47.         return $this->render('TroikaRealEstateBundle:About:analytic.html.twig', ['analytics' => $analytics'year' => null'date' => $date'page' => $page]
  48.         );
  49.     }
  50.     public function analyticByYearAction($year)
  51.     {
  52.         $page $_GET['page'] ?? 1;
  53.         $analytics $this->container->get('analytic.model')->getPageByYear($page$year);
  54.         $em $this->getDoctrine()->getEntityManager();
  55.         $connection $em->getConnection();
  56.         $statement =
  57.           $connection->prepare("select left(date,4) as date, count(*) from Analytic where published = 1 
  58.                                                     group by left(date,4) order by left(date,4) DESC");
  59.         $statement->execute();
  60.         $date $statement->fetchAll();
  61.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  62.         return $this->render(
  63.           'TroikaRealEstateBundle:About:analytic.html.twig',
  64.           ['analytics' => $analytics'year' => $year'date' => $date'page' => $page]
  65.         );
  66.     }
  67.     public function analyticItemAction($item)
  68.     {
  69.         $analytic $this->container->get('analytic.model')->getSlug($item);
  70.         if (empty($analytic)) {
  71.             throw new NotFoundHttpException();
  72.         }
  73.         $em $this->getDoctrine()->getEntityManager();
  74.         $connection $em->getConnection();
  75.         $statement =
  76.           $connection->prepare("select left(date,4) as date, 
  77.        count(*) from Analytic where published = 1 group by left(date,4) order by left(date,4) DESC");
  78.         $statement->execute();
  79.         $date $statement->fetchAll();
  80.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  81.         return $this->render('TroikaRealEstateBundle:About:analytic_item.html.twig', ['analytic' => $analytic'date' => $date'page' => $page]);
  82.     }
  83.     public function contactsAction()
  84.     {
  85.         $contacts $this->container->get('contact.model')->getAll();
  86.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  87.         return $this->render('TroikaRealEstateBundle:About:contacts.html.twig', ['contacts' => $contacts,'page'=>$page]);
  88.     }
  89.     public function faveAction()
  90.     {
  91.         
  92.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  93.         return $this->render('TroikaRealEstateBundle:About:fave.html.twig', ['page'=>$page]);
  94.     }
  95.     public function faveListAction(Request $request)
  96.     {
  97.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  98.         $lots $request->get('lots');
  99.         $lots $this->container->get('lot.model')->getFave($lots);
  100.         return $this->render('TroikaRealEstateBundle:EstateList:fave.item.html.twig', ['lots' => $lots,'page'=>$page]);
  101.     }
  102.     public function indexAction(\Symfony\Component\HttpFoundation\Request $request)
  103.     {
  104.         
  105.         $recent $this->get('lot.model')->getRecent();
  106.         $items $this->get('menuitem.model')->getActive();
  107.         $repository $this->getDoctrine()->getRepository('TroikaMainBundle:Home');
  108.         $home $repository->find(1);
  109.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  110.         $tagSlots $this->getDoctrine()->getRepository('TroikaMainBundle:TagSlot')->findAll();
  111.         $types $this->getDoctrine()->getRepository('TroikaMainBundle:TypeHouse')->findAll();
  112.         $districts $this->get('district.model')->getInUseSale(1);
  113.         $settlements $this->get('settlement.model')->getInUseSale(2);
  114.         $adistricts $this->get('district.model')->getInUseRent(1);
  115.         $districts_com $this->get('district.model')->getInUseSale(3);
  116.         $adistricts_com $this->get('district.model')->getInUseRent(3);
  117.         $subways $this->get('subway.model')->getInUseSale(3);
  118.         $translit = new GenerateShitFiltersCommand();
  119.         foreach ($subways as &$subway) {
  120.             $subway['enName'] = $translit->toAscii($translit->str2url($subway['name']));
  121.         }
  122.         foreach ($settlements as &$settlement) {
  123.             $settlement['enName'] = $translit->toAscii($translit->str2url($settlement['name']));
  124.         }
  125.         foreach ($districts as &$district) {
  126.             $district['enName'] = $translit->toAscii($translit->str2url($district['name']));
  127.         }
  128.         foreach ($districts_com as &$district_com) {
  129.             $district_com['enName'] = $translit->toAscii($translit->str2url($district_com['name']));
  130.         }
  131.         foreach ($adistricts as &$district) {
  132.             $district['enName'] = $translit->toAscii($translit->str2url($district['name']));
  133.         }
  134.         foreach ($adistricts_com as &$district_com) {
  135.             $district_com['enName'] = $translit->toAscii($translit->str2url($district_com['name']));
  136.         }
  137.         $highways $this->get('highway.model')->getInUseSale(2);
  138.         $ahighways $this->get('highway.model')->getInUseRent(2);
  139.         foreach ($highways as &$highway) {
  140.             $highway['enname'] = $translit->toAscii($translit->str2url($highway['name']));
  141.         }
  142.         foreach ($ahighways as &$highway) {
  143.             $highway['enname'] = $translit->toAscii($translit->str2url($highway['name']));
  144.         }
  145.         $countries $this->get('country.model')->getInUseSale(4);
  146.         $acountries $this->get('country.model')->getInUseRent(4);
  147.         foreach ($countries as &$country) {
  148.             $country['enname'] = $translit->toAscii($translit->str2url($country['name']));
  149.         }
  150.         foreach ($acountries as &$country) {
  151.             $country['enname'] = $translit->toAscii($translit->str2url($country['name']));
  152.         }
  153.         $blog $this->getDoctrine()->getRepository('TroikaMainBundle:Blog')->findAll();
  154.         if ($page->getPromoType() == "filter") {
  155.             $filter $page->filter->getAttributes();
  156.             if ($filter['price'] && $filter['price']['max']) {
  157.                 $filter['price']['max'] = $this->get('troika_main.currency')->getDollars($filter['price']['max'] / 10001);
  158.             }
  159.             if ($filter['price'] && $filter['price']['min']) {
  160.                 $filter['price']['min'] = $this->get('troika_main.currency')->getDollars($filter['price']['min'] / 10001);
  161.             }
  162.             $f_lots $this->get('lot.model')->getByFilter($filter);
  163.             $page->filter->lots $f_lots;
  164.         }
  165.         $r $request;
  166.         $complexes $this->get('lot.model')->getComplexesList($r);
  167.         $complexesAll $this->getDoctrine()->getRepository('TroikaMainBundle:ComplexPage')->findBy([], ['name' => 'ASC']);
  168.         $districtsAll $this->getDoctrine()->getRepository('TroikaMainBundle:Area2')->findAll();
  169.         $subwaysAll $this->getDoctrine()->getRepository('TroikaMainBundle:Subway2')->findAll();
  170.         $districts_t = [];
  171.         $subways_t = [];
  172.         $cs = [];
  173.         $districtIds = [];
  174.         $subwayIds = [];
  175.         foreach ($complexesAll as $complex) {
  176.             $cs[] = $complex->getName();
  177.             if (!in_array($complex->getArea2()->getId(), $districtIdstrue)) {
  178.                 $districtIds[] = $complex->getArea2()->getId();
  179.             }
  180.             if (!in_array($complex->getSubway2()->getId(), $subwayIdstrue)) {
  181.                 $subwayIds[] = $complex->getSubway2()->getId();
  182.             }
  183.         }
  184.         foreach ($districtIds as $id) {
  185.             foreach ($districtsAll as $district) {
  186.                 if ($id == $district->getId()) {
  187.                     $districts_t[] = $district;
  188.                 }
  189.             }
  190.         }
  191.         foreach ($subwayIds as $id) {
  192.             foreach ($subwaysAll as $subway) {
  193.                 if ($id == $subway->getId()) {
  194.                     $subways_t[] = $subway;
  195.                 }
  196.             }
  197.         }
  198.         $cityNum $this->get('lot.model')->getByCityFilter([
  199.           "sorter"    => ["order" => "date""direction" => "desc"],
  200.           "page"      => 1,
  201.           'lot'       => 1,
  202.           'operation' => 1,
  203.           "price"     => [
  204.             [
  205.               "min" => 0,
  206.               "max" => 100_000_000,
  207.             ],
  208.           ],
  209.           "space"     => [
  210.             [
  211.               "min" => 0,
  212.               "max" => 100_000_000,
  213.             ],
  214.           ],
  215.         ]);
  216.         $cityNum $cityNum['count'];
  217.         $subNum $this->get('lot.model')->getBySuburbanFilter([
  218.           "sorter"    => ["order" => "date""direction" => "desc"],
  219.           "page"      => 1,
  220.           'lot'       => 2,
  221.           'operation' => 1,
  222.           "price"     => [
  223.             [
  224.               "min" => 0,
  225.               "max" => 100_000_000,
  226.             ],
  227.           ],
  228.           "space"     => [
  229.             [
  230.               "min" => 0,
  231.               "max" => 100_000_000,
  232.             ],
  233.           ],
  234.           "distance"  => [
  235.             [
  236.               "min" => 0,
  237.               "max" => 100,
  238.             ],
  239.           ],
  240.         ]);
  241.         $subNum $subNum['count'];
  242.         $comNum $this->get('lot.model')->getByCityFilter([
  243.           "sorter"    => ["order" => "date""direction" => "desc"],
  244.           "page"      => 1,
  245.           'lot'       => 3,
  246.           'operation' => 1,
  247.           "price"     => [
  248.             [
  249.               "min" => 0,
  250.               "max" => 100_000_000,
  251.             ],
  252.           ],
  253.           "space"     => [
  254.             [
  255.               "min" => 0,
  256.               "max" => 100_000_000,
  257.             ],
  258.           ],
  259.         ]);
  260.         $comNum $comNum['count'];
  261.         $newNum $complexes->getTotalItemCount();
  262.         return $this->render(
  263.           'TroikaRealEstateBundle:Pages:main.html.twig',
  264.           [
  265.             'blog'           => $blog,
  266.             'page'           => $page,
  267.             'recent'         => $recent,
  268.             'items'          => $items,
  269.               //'slider'         => $slider,
  270.             'ogImg'          => null,
  271.             'title'          => $page->getMetaTitle(),
  272.             'description'    => $page->getMetaDescription(),
  273.             'keywords'       => $page->getMetaKeywords(),
  274.             'content'        => $home->getContent(),
  275.             'types'          => $types,
  276.             'districts'      => $districts,
  277.             'districts_com'  => $districts_com,
  278.             'highways'       => $highways,
  279.             'countries'      => $countries,
  280.             'settlements'    => $settlements,
  281.             'adistricts'     => $adistricts,
  282.             'adistricts_com' => $adistricts_com,
  283.             'ahighways'      => $ahighways,
  284.             'acountries'     => $acountries,
  285.             'tagSlots'       => $tagSlots,
  286.             'subways'        => $subways,
  287.             'districts_t'    => $districts_t,
  288.             'subways_t'      => $subways_t,
  289.             'cityNum'        => $cityNum,
  290.             'subNum'         => $subNum,
  291.             'comNum'         => $comNum,
  292.             'newNum'         => $newNum,
  293.           ]
  294.         );
  295.     }
  296.     public function indexRedirectAction()
  297.     {
  298.         return $this->redirect("/"301);;
  299.     }
  300.     public function mapAction()
  301.     {
  302.         $preset_city = [
  303.           "sale" => [
  304.             "area"      => $this->get('filter_preset.model')->getPresetByAttr('District3'11),
  305.             "TypeHouse" => $this->get('filter_preset.model')->getPresetByAttr('TypeHouse'11),
  306.             "subway"    => $this->get('filter_preset.model')->getPresetByAttr('Subway2'11),
  307.           ],
  308.           "rent" => [
  309.             "area"      => $this->get('filter_preset.model')->getPresetByAttr('District3'12),
  310.             "TypeHouse" => $this->get('filter_preset.model')->getPresetByAttr('TypeHouse'12),
  311.             "subway"    => $this->get('filter_preset.model')->getPresetByAttr('Subway2'12),
  312.           ],
  313.         ];
  314.         $preset_suburban = [
  315.           "sale" => [
  316.             "highway"    => $this->get('filter_preset.model')->getPresetByAttr('Highway'21),
  317.             "settlement" => $this->get('filter_preset.model')->getPresetByAttr('Settlement'21),
  318.             "TypeHouse"  => $this->get('filter_preset.model')->getPresetByAttr('TypeHouse'21),
  319.           ],
  320.         ];
  321.         $preset_foreign = [
  322.           "sale" => $this->get('filter_preset.model')->getPresetByAttr('Country'41),
  323.           "rent" => $this->get('filter_preset.model')->getPresetByAttr('Country'42),
  324.         ];
  325.         return $this->render('TroikaRealEstateBundle:Map:map.html.twig', [
  326.             'preset_city'     => $preset_city,
  327.             'preset_suburban' => $preset_suburban,
  328.             'preset_foreign'  => $preset_foreign,
  329.           ]
  330.         );
  331.     }
  332.     public function n_servicesAction()
  333.     {
  334.         $repository $this->getDoctrine()->getRepository('TroikaMainBundle:NServices');
  335.         $about $repository->find(1);
  336.         return $this->render('TroikaRealEstateBundle:About:n_services.html.twig', [
  337.           'title'       => $about->getTitle(),
  338.           'description' => $about->getDescription(),
  339.           'keywords'    => $about->getKeywords(),
  340.           'content1'    => $about->getContent1(),
  341.           'content2'    => $about->getContent2(),
  342.           'content3'    => $about->getContent3(),
  343.           'content4'    => $about->getContent4(),
  344.           'img1'        => $about->getWebPathImg1(),
  345.           'img2'        => $about->getWebPathImg2(),
  346.           'img3'        => $about->getWebPathImg3(),
  347.           'img4'        => $about->getWebPathImg4(),
  348.         ]);
  349.     }
  350.     public function newsAction()
  351.     {
  352.         $page $_GET['page'] ?? 1;
  353.         $news $this->container->get('news.model')->getPage($page);
  354.         return $this->render('TroikaRealEstateBundle:About:news.html.twig', ['news' => $news'year' => null]);
  355.     }
  356.     public function newsByYearAction($year)
  357.     {
  358.         $date getdate();
  359.         if ($year 2009) {
  360.             return $this->redirectToRoute('troika_year_news', ['year' => 2009], 301);
  361.         } elseif ($year $date['year']) {
  362.             return $this->redirectToRoute('troika_year_news', ['year' => $date['year']], 301);
  363.         }
  364.         $page $_GET['page'] ?? 1;
  365.         $news $this->container->get('news.model')->getPageByYear($page$year);
  366.         return $this->render('TroikaRealEstateBundle:About:news.html.twig', ['news' => $news'year' => $year]);
  367.     }
  368.     public function newsItemAction($id)
  369.     {
  370.         $news $this->container->get('news.model')->getOne($id);
  371.         $links $this->container->get('news.model')->getPage(1);
  372.         return $this->render('TroikaRealEstateBundle:About:news_item.html.twig', ['news' => $news'links' => $links]);
  373.     }
  374.     public function newsItemSlugAction($slug$id)
  375.     {
  376.         $news $this->container->get('news.model')->getSlug($slug$id);
  377.         $links $this->container->get('news.model')->getPage(1);
  378.         if (!$news) {
  379.             throw $this->createNotFoundException('The news does not exist');
  380.         }
  381.         return $this->render('TroikaRealEstateBundle:About:news_item.html.twig', ['news' => $news'links' => $links]);
  382.     }
  383.     public function partnersAction()
  384.     {
  385.         $blog $this->getDoctrine()->getRepository('TroikaMainBundle:Blog')->findAll();
  386.         $partners $this->getDoctrine()->getRepository('TroikaMainBundle:Partners')->findAll();
  387.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  388.         return $this->render('TroikaRealEstateBundle:About:partners.html.twig', ['partners' => $partners'page' => $page]);
  389.     }
  390.     public function pressAction()
  391.     {
  392.         $em $this->getDoctrine()->getEntityManager();
  393.         $connection $em->getConnection();
  394.         $statement =
  395.           $connection->prepare("select left(date,4) as date, count(*) from Press group by left(date,4) order by left(date,4) DESC");
  396.         $statement->execute();
  397.         $date $statement->fetchAll();
  398.         $page $_GET['page'] ?? 1;
  399.         $presses $this->container->get('press.model')->getPage($page);
  400.         return $this->render('TroikaRealEstateBundle:About:press.html.twig', ['presses' => $presses'date' => $date'year' => null]);
  401.     }
  402.     public function pressByYearAction($year)
  403.     {
  404.         $page $_GET['page'] ?? 1;
  405.         $press $this->container->get('press.model')->getPageByYear($page$year);
  406.         $em $this->getDoctrine()->getEntityManager();
  407.         $connection $em->getConnection();
  408.         $statement =
  409.           $connection->prepare("select left(date,4) as date, count(*) from Press group by left(date,4) order by left(date,4) DESC");
  410.         $statement->execute();
  411.         $date $statement->fetchAll();
  412.         return $this->render('TroikaRealEstateBundle:About:press.html.twig', ['presses' => $press'year' => $year'date' => $date]);
  413.     }
  414.     public function servicesAction()
  415.     {
  416.         $repository $this->getDoctrine()->getRepository('TroikaMainBundle:Service');
  417.         $service $repository->find(1);
  418.         $blog $this->getDoctrine()->getRepository('TroikaMainBundle:Blog')->findAll();
  419.         return $this->render('TroikaRealEstateBundle:About:services.html.twig', [
  420.           'title'       => $service->getTitle(),
  421.           'description' => $service->getDescription(),
  422.           'keywords'    => $service->getKeywords(),
  423.           'content'     => $service->getContent(),
  424.           'blog'        => $blog,
  425.         ]);
  426.     }
  427. }