src/Controller/WebPagesController.php line 569

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Doctrine\Persistence\ManagerRegistry;
  4. use Symfony\Component\HttpKernel\KernelInterface;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  13. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  14. use Symfony\Component\Form\Extension\Core\Type\FileType;
  15. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  16. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  17. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  18. use EasyCorp\Bundle\EasyAdminBundle\Form\Type\CodeEditorType;
  19. use App\Entity\Eshop;
  20. use App\Entity\Gallery;
  21. use App\Entity\GalleryItem;
  22. use App\Entity\Website;
  23. use App\Entity\WebMenu;
  24. use App\Entity\WebMenuItem;
  25. use App\Entity\WebPage;
  26. use App\Entity\WireFrame;
  27. use App\Entity\Module;
  28. use App\Entity\Service;
  29. use App\Entity\User;
  30. use App\Entity\Language;
  31. use App\Entity\CssDesign;
  32. use App\Entity\ServiceExample;
  33. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  34. use App\Entity\Contact;
  35. use Symfony\Contracts\Translation\TranslatorInterface;
  36. use Twig\Environment;
  37. class WebPagesController extends DefaultController
  38. {
  39.     protected KernelInterface $appKernel;
  40.     protected ManagerRegistry $doctrine;
  41.     protected TranslatorInterface $translator;
  42.     protected Environment $twig;
  43.     public function __construct(KernelInterface $appKernel,
  44.                                 ManagerRegistry $doctrine,
  45.                                 TranslatorInterface $translator,
  46.                                 Environment $twig)
  47.     {
  48.         $this->appKernel $appKernel;
  49.         $this->doctrine $doctrine;
  50.         $this->translator $translator;
  51.         $this->twig $twig;
  52.     }
  53.     /**
  54.      * @Route("/webpages", name="webpages")
  55.      */
  56.     public function indexAction(Request $request)
  57.     {
  58.         /* we load session data */
  59.         parent::init($request);
  60.         $session $request->getSession();
  61.         /* we load entity managers */
  62.         $em $this->doctrine->getManager();
  63.         /* we get current user */
  64.         if ($session->get('user')) {
  65.             $currentUserId $session->get('user')->getUserId();
  66.         } else {
  67.             $currentUserId null;
  68.         }
  69.         if ($currentUserId) {
  70.             $user $em->getRepository(User::class)->getUser($currentUserId);
  71.         } else {
  72.             $user null;
  73.         }
  74.         /* we load list of modules for connector service */
  75.         $service $em->getRepository(Service::class)->getService(3);
  76.         /* we load examples */
  77.         $exampleCollection $em->getRepository(ServiceExample::class)->getServiceExampleListByService(33);
  78.         shuffle($exampleCollection);              
  79.         /* we render data */
  80.         return $this->render('webpages.html.twig',
  81.             array('headerData' => $this -> getPageHeader($request),
  82.                   'moduleList' => $service->getModules(),
  83.                   'exampleCollection' => $exampleCollection,
  84.                   'service' => $service,
  85.                   'user' => $user,
  86.             )
  87.         );        
  88.     }
  89.     /**
  90.      * @Route("/webpagesAdmin", name="webpagesAdmin")
  91.      */
  92.     public function webpagesAdminAction(Request $request)
  93.     {
  94.     
  95.         /* we load session data */
  96.         parent::init($request);
  97.     
  98.         $session $request->getSession();
  99.         /* we check if user is logged in */
  100.         if(empty($session->get('user'))) {
  101.             return $this->redirectToRoute('login');
  102.         }        
  103.         /* we load entity managers */
  104.         $em $this->doctrine->getManager();
  105.         $dem $this->doctrine->getManager('dynamic_em');
  106.         
  107.         /* we get current user */
  108.         $currentUserId $session->get('user')->getUserId();
  109.         $user $em->getRepository(User::class)->getUser($currentUserId);
  110.         /* setting current webpages */
  111.         if(!empty($request->query->get('setCurrent'))) {
  112.             $website $em->getRepository(Website::class)->getWebsite($request->query->get('setCurrent'));
  113.             $em->getRepository(Website::class)->setCurrentWebsite($currentUserId$request->query->get('setCurrent'));
  114.             $session->set('website'$website);
  115.         
  116.             $this->addFlash('notice''The website '.$website->getWebsiteName().' was set as current one.');
  117.             return $this->redirectToRoute('webpagesAdmin');
  118.         
  119.         }
  120.         /* we get current website */
  121.         $currentWeb $em->getRepository(Website::class)->getCurrentWebsite($currentUserId);
  122.          
  123.         /* we load list of websites for logged user */
  124.         $websiteList $em->getRepository(Website::class)->getWebsiteListByUser($currentUserId);
  125.         //we create new web if there is none
  126.         if(count($websiteList) == 0) {
  127.             $this->webCreate($request);
  128.             return $this->redirectToRoute('webpagesAdmin'); 
  129.         }
  130.         /* 
  131.         print('<br>qqw count web: '.count($websiteList));
  132.         print('<br>qqw current web: ');
  133.         \Doctrine\Common\Util\Debug::dump($currentWeb); 
  134.         */
  135.         /* if there is no current website set then we set one */
  136.         if(empty($currentWeb) && count($websiteList) == 1) {
  137.             //print('<br>qqw setting current web ');
  138.             $website $websiteList[0];
  139.             $em->getRepository(Website::class)->setCurrentWebsite($currentUserId$website->getWebsiteId());
  140.             $session->set('website'$website);
  141.         }
  142.  
  143.         /* we display lists of menus, pages etc only if there is current website */
  144.         if(!empty($currentWeb)) { 
  145.             /* we load list of web pages for the current website */
  146.             $webPageList $dem->getRepository(WebPage::class)->getWebPageListByWebsite($currentWeb->getWebsiteId());
  147.      
  148.             /* we load list of web menus for the current website */
  149.             $webMenuList $dem->getRepository(WebMenu::class)->getWebMenuListByWebsite($currentWeb->getWebsiteId());
  150.             /* we load header for the current website */
  151.             $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($currentWeb->getWebsiteId());
  152. //            print('<br>webPageHeader: ');
  153. //            print_r($webPageHeader);
  154.             /* we load footer for the current website */
  155.             $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($currentWeb->getWebsiteId());
  156.         } else {
  157.             $webPageList = array();
  158.             $webMenuList = array();
  159.             $webPageHeader null;
  160.             $webPageFooter null;
  161.         }
  162.         /* we load list of wireframes */
  163.         $wireFrameList $em->getRepository(WireFrame::class)->getWireFrameList();
  164.           
  165.         /* we prepare array of wireframes */
  166.         $wireFrameArray = array();
  167.         foreach($wireFrameList as $wireFrame) {
  168.             $wireFrameArray[$wireFrame->getWireFrameId()] = $wireFrame;
  169.         }
  170.         
  171.         /* we prepare array of count(pages) */
  172.         $webPageCountArray = array();
  173.         foreach($websiteList as $website) {
  174.             $webPageCountArray[$website->getWebsiteId()] = $dem->getRepository(WebPage::class)->getWebPageCountByWebsite($website->getWebsiteId());
  175.         }    
  176.         
  177.         /*
  178.         print('<br>qqw PageCount: ');
  179.         \Doctrine\Common\Util\Debug::dump($webPageCountArray);
  180.         */     
  181.         
  182.         /* we load list of modules for website service */
  183.         $service $em->getRepository(Service::class)->getService(3);
  184.         $moduleCollection $em->getRepository(Module::class)->getModuleList();
  185.         /* we render data */
  186.         return $this->render('webpagesAdmin.html.twig',
  187.                 array(    'headerData' => $this -> getPageHeader($request),
  188.                         'websiteList' => $websiteList,
  189.                         'webPageList' => $webPageList,
  190.                         'webPageHeader' => $webPageHeader,
  191.                         'webPageFooter' => $webPageFooter,
  192.                         'webMenuList' => $webMenuList,
  193.                         'wireFrameArray' => $wireFrameArray,
  194.                         'webPageCountArray' => $webPageCountArray,
  195.                         'moduleList' => $service->getModules(),
  196.                         'userModuleList' => $user->getModules(),                        
  197.                         'menu' => $this -> adminMenu($request),
  198.                         'mainMenu' => $this -> adminMainMenu($request),
  199.                         'user' => $user
  200.                 )
  201.                 );
  202.     
  203.     }
  204.     
  205.     /**
  206.      * @Route("/webPagesHeader", name="webPagesHeader")
  207.      */
  208.     public function webPagesHeaderAction(Request $request)
  209.     {
  210.     
  211.         /* we load session data */
  212.         parent::init($request);
  213.         $session $request->getSession();
  214.     
  215.         /* we load users entity manager */
  216.         $em $this->doctrine->getManager();
  217.         //$dem = $this->doctrine->getManager('dynamic_em');
  218.          
  219.         /* we get current user */
  220.         $currentUserId $session->get('user')->getUserId();
  221.         $user $em->getRepository(User::class)->getUser($currentUserId);
  222.         /* we render data */
  223.         return $this->render('webpagesHeader.html.php',
  224.                 array(    'headerData' => $this -> getPageHeader($request),
  225.                         'menu' => $this -> adminMenu($request),
  226.                         'mainMenu' => $this -> adminMainMenu($request),
  227.                         'mainMenu' => $this -> adminMainMenu($request),
  228.                 )
  229.                 );
  230.     
  231.     }    
  232.     
  233.     /**
  234.      * @Route("/webnew", name="webNew")
  235.      */
  236.     public function webNewAction(Request $request)
  237.     {
  238.     
  239.         /* we load session data */
  240.         parent::init($request);
  241.     
  242.         $session $request->getSession();
  243.     
  244.         $em $this->doctrine->getManager();
  245.         $userId $session->get('user')->getUserId();
  246.         $user $em->getRepository(User::class)->getUser($userId);
  247.     
  248.         /* we build form */
  249.         $formBuilder $this->createFormBuilder();
  250.     
  251.         $formBuilder->add('websiteName'TextType::class, array(
  252.                 'required' => true,
  253.                 'label' => $this->translator->trans('webpages.name'),
  254.                 'attr' => array('class' => 'text_form''size' => 22),
  255.                 'label_attr' => array('class' => 'form_field_label'),
  256.         ));
  257.          
  258.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('form.button.save'),
  259.                 'attr' => array('class' => 'butt_big')));
  260.     
  261.         $form $formBuilder->getForm();
  262.         $form->handleRequest($request);
  263.     
  264.         if ($request->getMethod() == 'POST') {
  265.     
  266.             if ($form->isValid()) {
  267.                 // perform some action, such as save the object to the database
  268.     
  269.                 /* we load users entity manager */
  270.                 //$dem = $this->doctrine->getManager('dynamic_em');
  271.     
  272.                 $website = new Website;
  273.                 $website->setWebsiteName($request->request->get('form')['websiteName']);
  274.                 $website->setUserId($session->get('user')->getUserId());
  275.                 /* we persist and save */
  276.                 $em->persist($website);
  277.                 $em->flush();
  278.     
  279.                 $this->addFlash('notice''New website was created.');
  280.     
  281.                 return $this->redirectToRoute('webpagesAdmin');
  282.     
  283.             }
  284.              
  285.         }
  286.     
  287.         /* we render data */
  288.         return $this->render('webNew.html.twig',
  289.                 array(    'form' => $formBuilder->getForm()->createView(),
  290.                         'headerData' => $this -> getPageHeader($request),
  291.                         'menu' => $this -> adminMenu($request),
  292.                         'mainMenu' => $this -> adminMainMenu($request),
  293.                         'user' => $user,
  294.                 )
  295.                 );
  296.     
  297.     }
  298.     
  299.     /**
  300.      * @Route("/web/{webId}", name="web")
  301.      */
  302.     public function webAction(Request $request$webId)
  303.     {
  304.     
  305.         /* we load session data */
  306.         parent::init($request);
  307.         $session $request->getSession();
  308.         //print('<br>QQW web ID: '.$webId);
  309.     
  310.         /* we load entity managers */
  311.         $em $this->doctrine->getManager();
  312.         $dem $this->doctrine->getManager('dynamic_em');
  313.          
  314.         /* we get current web */
  315.         $web $em->getRepository(Website::class)->getWebsite($webId);
  316.         try {
  317.             //print('<br>Twig - adds php functions ...');
  318.             $this->twig->addFunction(new \Twig\TwigFunction('deg2rad''deg2rad'));
  319.             $this->twig->addFunction(new \Twig\TwigFunction('sin''sin'));
  320.             $this->twig->addFunction(new \Twig\TwigFunction('imagecreatefromstring''imagecreatefromstring'));
  321.             $this->twig->addFunction(new \Twig\TwigFunction('file_get_contents''file_get_contents'));
  322.             $this->twig->addFunction(new \Twig\TwigFunction('ImageSX''ImageSX'));
  323.             $this->twig->addFunction(new \Twig\TwigFunction('ImageSY''ImageSY')); 
  324.         } catch(Exception $e) {
  325.             $this->addFlash('error'"Twig functions init error");
  326.         }
  327.          
  328.         /* we load header for the current website */
  329.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  330.          
  331.         /* we load footer for the current website */
  332.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  333.         $webPageLeftColumn $dem->getRepository(WebPage::class)->getWebPageLeftColumn($webId);
  334.         $webPageRightColumn $dem->getRepository(WebPage::class)->getWebPageRightColumn($webId);
  335.          
  336.         /* we load main menu for the current website */
  337.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  338.         if(!empty($webMenuMain)) {
  339.             $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  340.         } else {
  341.            $webMenuItemList = array();
  342.         }
  343.         /* we load top menu for the current website */
  344.         $webMenuTop $dem->getRepository(WebMenu::class)->getTopMenu($webId);
  345.         if(!empty($webMenuTop)) {
  346.            $webMenuTopItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuTop->getWebMenuId());
  347.         } else {
  348.            $webMenuTopItemList = array();
  349.         }
  350.         /* we load home page for the current website */
  351.         $homePage $dem->getRepository(WebPage::class)->getHomePage($webId);
  352.         $currentLang $session->get('lang');
  353.         $homePageContent '';
  354.         $webPageHeaderContent '';
  355.         $webPageFooterContent '';
  356.         foreach($web->getLanguages() as $lang) {
  357.             if ($lang->getLangKey() == $currentLang->getLangKey()) {
  358.                 
  359.                 if(!empty($homePage)) {
  360.                     $homePage->setLocale($lang->getLangKey());
  361.                     $dem->refresh($homePage);
  362.                     $homePageContent $homePage->getWebPageContent();                    
  363.                 }
  364.                 if(!empty($webPageHeader)) {
  365.                     $webPageHeader->setLocale($lang->getLangKey());
  366.                     $dem->refresh($webPageHeader);
  367.                     $webPageHeaderContent $webPageHeader->getWebPageContent();
  368.                 }    
  369.                 if(!empty($webPageFooter)) {
  370.                     $webPageFooter->setLocale($lang->getLangKey());
  371.                     $dem->refresh($webPageFooter);
  372.                     $webPageFooterContent $webPageFooter->getWebPageContent();
  373.                 }    
  374.             }
  375.         }
  376.         //print('<br>webPageHeaderContent in '.$currentLang->getLangKey().': '.$webPageHeaderContent);
  377. //        print('<br>homePageContent in '.$currentLang->getLangKey().': '.$homePageContent);
  378. //        print('<br>webPageFooterContent in '.$currentLang->getLangKey().': '.$webPageFooterContent);
  379.         $seoData = array();
  380.         $seoData['seoTitle'] = '';
  381.         $seoData['seoDescription'] = '';  
  382.         /* we parse the page content for placeholders */
  383.         if(!empty($homePage)) { 
  384.           $homePageContent $this->parseContent($request$homePageContent);
  385.           $homePage->setWebPageContent($homePageContent);
  386.           $seoData['seoTitle'] = $homePage->getSeoTitle();
  387.           $seoData['seoDescription'] = $homePage->getSeoDescription();           
  388.         }
  389.         if(!empty($webPageHeader)) {
  390.             $webPageHeader->setWebPageContent($webPageHeaderContent);
  391.         }
  392.         if(!empty($webPageFooter)) {
  393.             $webPageFooter->setWebPageContent($webPageFooterContent);
  394.         }
  395. //        print('<hr>qqw homePage Content 2: '.$homePageContent.'<hr>');
  396. //        \Doctrine\Common\Util\Debug::dump($homePage);
  397.         /* we check if website exists */
  398.         if($web === null) {
  399.             $this->addFlash('error''Web with tis ID does not exists.');
  400.             return $this->redirectToRoute('webHome');
  401.         }
  402.         
  403.         /* we get wireframe */
  404.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  405. //        print('<hr>qqw wireframe: ');
  406. //        \Doctrine\Common\Util\Debug::dump($wireFrame);
  407.         $webMenuVertical null;
  408.         $webMenuVerticalItemList null;
  409.         /* we load left column - vertical menu for the current website */
  410.         if($wireFrame->getWireFrameName() == 'Website Classic') {
  411.             $webMenuVertical $dem->getRepository(WebMenu::class)->getVerticalMenu($webId);
  412.             if(!empty($webMenuVertical)) {
  413.                 $webMenuVerticalItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuVertical->getWebMenuId());
  414.             }
  415.         }
  416.         /*
  417.         print('<hr>qqw webMenuVertical: ');
  418.         \Doctrine\Common\Util\Debug::dump($webMenuVertical);
  419.         print('<hr>qqw webMenuVerticalItemList: ');
  420.         \Doctrine\Common\Util\Debug::dump($webMenuVerticalItemList);
  421.         */
  422.         //print('<br>menu : ');
  423.         //\Doctrine\Common\Util\Debug::dump($webMenuTop);
  424.         //foreach ($webMenuTopItemList as $menuItem) {
  425.             //$menuItem->setLocale($session->get('lang'));
  426.             //$dem->refresh($menuItem);
  427.             //print('<br>menu item: '.$menuItem->getWebMenuItemName());
  428.         //}
  429.     
  430.         /* we render data */
  431.         return $this->render('web.html.twig',
  432.                 array(  'headerData' => $this -> getPageHeader($request),
  433.                         'seoData' => $seoData,                    
  434.                         'menu' => $this -> adminMenu($request),
  435.                         'mainMenu' => $this -> adminMainMenu($request),
  436.                         'web' => $web,
  437.                         'wireFrame' => $wireFrame,
  438.                         'webPageHeader' => $webPageHeader,
  439.                         'webPageFooter' => $webPageFooter,
  440.                         'webPageLeftColumn' => $webPageLeftColumn,
  441.                         'webPageRightColumn' => $webPageRightColumn,
  442.                         'webMenuMain' => $webMenuMain,
  443.                         'webMenuTop' => $webMenuTop,                        
  444.                         'webMenuItemList' => $webMenuItemList,
  445.                         'webMenuTopItemList' => $webMenuTopItemList,                        
  446.                         'webMenuVertical' => $webMenuVertical,
  447.                         'webMenuVerticalItemList' => $webMenuVerticalItemList,                        
  448.                         'homePage' => $homePage,
  449.                 )
  450.                 );
  451.     
  452.     }  
  453.     
  454.     /**
  455.      * @Route("/web/{webId}/page/{pageId}", name="page")
  456.      */
  457.     public function pageAction(Request $request$webId$pageId)
  458.     {
  459.     
  460.         /* we load session data */
  461.         parent::init($request);
  462.         $session $request->getSession();
  463.         //print('<br>QQW page ID: '.$pageId);
  464.     
  465.         /* we load entity managers */
  466.         $em $this->doctrine->getManager();
  467.         $dem $this->doctrine->getManager('dynamic_em');
  468.         /* we get current web */
  469.         $web $em->getRepository(Website::class)->getWebsite($webId);
  470.          
  471.         /* we load header for the current website */
  472.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  473.         /* we load footer for the current website */
  474.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  475.         $webPageLeftColumn $dem->getRepository(WebPage::class)->getWebPageLeftColumn($webId);
  476.         $webPageRightColumn $dem->getRepository(WebPage::class)->getWebPageRightColumn($webId);
  477.          
  478.         /* we load header for the current website */
  479.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  480.         if(!empty($webMenuMain)) {
  481.            $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  482.         } else {
  483.            $webMenuItemList = array();
  484.         }
  485.         /* we load top menu for the current website */
  486.         $webMenuTop $dem->getRepository(WebMenu::class)->getTopMenu($webId);
  487.         if(!empty($webMenuTop)) {
  488.            $webMenuTopItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuTop->getWebMenuId());
  489.         } else {
  490.            $webMenuTopItemList = array();
  491.         }        
  492.         /* we load page for the current webpage */
  493.         $page $dem->getRepository(WebPage::class)->getWebPage($pageId);
  494.         $currentLang $session->get('lang');
  495.         
  496.         /*
  497.         print('<br>qqw page id: '.$pageId);
  498.         \Doctrine\Common\Util\Debug::dump($page);
  499.         */
  500.         $pageContent '';
  501.         $webPageHeaderContent '';
  502.         $webPageFooterContent '';
  503.         foreach($web->getLanguages() as $lang) {
  504.             if ($lang->getLangKey() == $currentLang->getLangKey()) {
  505.                 if(!empty($page)) {
  506.                     $page->setLocale($lang->getLangKey());
  507.                     $dem->refresh($page);
  508.                     $pageContent $page->getWebPageContent();
  509.                 }
  510.                 if(!empty($webPageHeader)) {
  511.                     $webPageHeader->setLocale($lang->getLangKey());
  512.                     $dem->refresh($webPageHeader);
  513.                     $webPageHeaderContent $webPageHeader->getWebPageContent();
  514.                 }
  515.                 if(!empty($webPageFooter)) {
  516.                     $webPageFooter->setLocale($lang->getLangKey());
  517.                     $dem->refresh($webPageFooter);
  518.                     $webPageFooterContent $webPageFooter->getWebPageContent();
  519.                 }
  520.             }
  521.         }
  522.         /* we parse the page content for placeholders */
  523.         $pageContent $this->parseContent($request$pageContent);
  524.         $page->setWebPageContent($pageContent);
  525.         //print('<br>page content2: '.$pageContent);
  526.         if(!empty($webPageHeader)) {
  527.             $webPageHeader->setWebPageContent($webPageHeaderContent);
  528.         }
  529.         if(!empty($webPageFooter)) {
  530.             $webPageFooter->setWebPageContent($webPageFooterContent);
  531.         }
  532.         
  533.         /* we check if website exists */
  534.         if($web === null) {
  535.             $this->addFlash('error''Web with tis ID does not exists.');
  536.             return $this->redirectToRoute('webHome');
  537.         }
  538.         
  539.         /* we get wireframe */
  540.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  541.         $webMenuVertical null;
  542.         $webMenuVerticalItemList null;
  543.         /* we load left column - vertical menu for the current website */
  544.         if($wireFrame->getWireFrameName() == 'Website Classic') {
  545.             
  546.             $webMenuVertical $dem->getRepository(WebMenu::class)->getVerticalMenu($webId);
  547.             if(!empty($webMenuVertical)) {
  548.                 $webMenuVerticalItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuVertical->getWebMenuId());
  549.             }
  550.         }
  551.         /*
  552.         print('<br>qqw webMenuVertical: ');
  553.         \Doctrine\Common\Util\Debug::dump($webMenuVertical);
  554.         */
  555.         /* we render data */
  556.         return $this->render('page.html.twig',
  557.                 array(  'headerData' => $this -> getPageHeader($request),
  558.                         'menu' => $this -> adminMenu($request),
  559.                         'mainMenu' => $this -> adminMainMenu($request),
  560.                         'web' => $web,
  561.                         'wireFrame' => $wireFrame,
  562.                         'webPageHeader' => $webPageHeader,
  563.                         'webPageFooter' => $webPageFooter,
  564.                         'webPageLeftColumn' => $webPageLeftColumn,
  565.                         'webPageRightColumn' => $webPageRightColumn,
  566.                         'webMenuMain' => $webMenuMain,
  567.                         'webMenuItemList' => $webMenuItemList,
  568.                         'webMenuTop' => $webMenuTop,                        
  569.                         'webMenuTopItemList' => $webMenuTopItemList,                           
  570.                         'webMenuVertical' => $webMenuVertical,
  571.                         'webMenuVerticalItemList' => $webMenuVerticalItemList,                            
  572.                         'page' => $page,
  573.                 )
  574.                 );
  575.     
  576.     }  
  577.     /**
  578.      * @Route("/web/{webId}/galleries", name="webGalleries")
  579.      */
  580.     public function webGalleriesAction(Request $request$webId)
  581.     {
  582.     
  583.         /* we load session data */
  584.         parent::init($request);
  585.         $session $request->getSession();
  586. //        print('<br>QQW web ID: '.$webId);
  587.     
  588.         /* we load entity managers */
  589.         $em $this->doctrine->getManager();
  590.         $dem $this->doctrine->getManager('dynamic_em');
  591.         /* we get current web */
  592.         $web $em->getRepository(Website::class)->getWebsite($webId);
  593.          
  594.         /* we load header for the current website */
  595.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  596.         if(!empty($webPageHeader)) {
  597.             $webPageHeader->setLocale($session->get('lang')->getLangKey());
  598.             $dem->refresh($webPageHeader);
  599.         }
  600.          
  601.         /* we load footer for the current website */
  602.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  603.         if(!empty($webPageFooter)) {
  604.             $webPageFooter->setLocale($session->get('lang')->getLangKey());
  605.             $dem->refresh($webPageFooter);
  606.         }
  607.         /* we load menu for the current website */
  608.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  609.         if(!empty($webMenuMain)) {
  610.            $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  611.         } else {
  612.            $webMenuItemList = array();
  613.         }
  614.         
  615.         /* we load top menu for the current website */
  616.         $webMenuTop $dem->getRepository(WebMenu::class)->getTopMenu($webId);
  617.         if(!empty($webMenuTop)) {
  618.            $webMenuTopItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuTop->getWebMenuId());
  619.         } else {
  620.            $webMenuTopItemList = array();
  621.         }   
  622.         /*
  623.         print('<br>qqw page id: '.$pageId);
  624.         \Doctrine\Common\Util\Debug::dump($page);
  625.         */           
  626.         
  627.         /* we check if website exists */
  628.         if($web === null) {
  629.             $this->addFlash('error''Web with tis ID does not exists.');
  630.             return $this->redirectToRoute('webHome');
  631.         }
  632.         
  633.         /* we get wireframe */
  634.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  635.         $webMenuVertical null;
  636.         $webMenuVerticalItemList null;
  637.         /* we load left column - vertical menu for the current website */
  638.         if($wireFrame->getWireFrameName() == 'Website Classic') {
  639.             
  640.             $webMenuVertical $dem->getRepository(WebMenu::class)->getVerticalMenu($webId);
  641.             if(!empty($webMenuVertical)) {
  642.                 $webMenuVerticalItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuVertical->getWebMenuId());
  643.             }
  644.         }
  645.         /* we get list of galleries */
  646.         $galleryList $dem->getRepository(Gallery::class)->getGalleryListByUser($web->getUserId());
  647.         //print('<br>qqw web: ');
  648.         //\Doctrine\Common\Util\Debug::dump($web);
  649.         /* we render data */
  650.         return $this->render('galleries.html.twig',
  651.                 array(  'headerData' => $this -> getPageHeader($request),
  652.                         'menu' => $this -> adminMenu($request),
  653.                         'mainMenu' => $this -> adminMainMenu($request),
  654.                         //'mainMenu' => $this -> adminMainMenu($request),
  655.                         'web' => $web,
  656.                         'wireFrame' => $wireFrame,
  657.                         'webPageHeader' => $webPageHeader,
  658.                         'webPageFooter' => $webPageFooter,
  659.                         'webMenuMain' => $webMenuMain,
  660.                         'webMenuItemList' => $webMenuItemList,
  661.                         'webMenuTop' => $webMenuTop,                        
  662.                         'webMenuTopItemList' => $webMenuTopItemList,                          
  663.                         'galleryList' => $galleryList,
  664.                         'webMenuVertical' => $webMenuVertical,  
  665.                         'webMenuVerticalItemList' => $webMenuVerticalItemList,                           
  666.                 )
  667.                 );
  668.     
  669.     }  
  670.     /**
  671.      * @Route("/web/{webId}/gallery/{galleryId}", name="webGallery")
  672.      */
  673.     public function webGalleryAction(Request $request$webId$galleryId)
  674.     {
  675.     
  676.         /* we load session data */
  677.         parent::init($request);
  678.         $session $request->getSession();
  679.         /* we load entity managers */
  680.         $em $this->doctrine->getManager();
  681.         $dem $this->doctrine->getManager('dynamic_em');
  682.         /* we get current web */
  683.         $web $em->getRepository(Website::class)->getWebsite($webId);
  684.         
  685.           /* we get user */
  686.           $userId $web->getUserId();
  687.           $user $em->getRepository(User::class)->getUser($userId);
  688.          
  689.         /* we load header for the current website */
  690.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  691.         if(!empty($webPageHeader)) {
  692.             $webPageHeader->setLocale($session->get('lang')->getLangKey());
  693.             $dem->refresh($webPageHeader);
  694.         }
  695.          
  696.         /* we load footer for the current website */
  697.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  698.         if(!empty($webPageFooter)) {
  699.             $webPageFooter->setLocale($session->get('lang')->getLangKey());
  700.             $dem->refresh($webPageFooter);
  701.         }
  702.          
  703.         /* we load header for the current website */
  704.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  705.         if(!empty($webMenuMain)) {
  706.            $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  707.         } else {
  708.            $webMenuItemList = array();
  709.         }
  710.         /* we load top menu for the current website */
  711.         $webMenuTop $dem->getRepository(WebMenu::class)->getTopMenu($webId);
  712.         if(!empty($webMenuTop)) {
  713.            $webMenuTopItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuTop->getWebMenuId());
  714.         } else {
  715.            $webMenuTopItemList = array();
  716.         }           
  717.         if(!empty($request->get('backUrl'))) {
  718.             $backUrl $request->get('backUrl');
  719.         } else {
  720.             $backUrl null;
  721.         }
  722.         
  723.         /*
  724.         print('<br>qqw page id: '.$pageId);
  725.         \Doctrine\Common\Util\Debug::dump($page);
  726.         */           
  727.         
  728.         /* we check if website exists */
  729.         if($web === null) {
  730.             $this->addFlash('error''Web with tis ID does not exists.');
  731.             return $this->redirectToRoute('webHome');
  732.         }
  733.         $userDirs $this->getUserFolderPaths($request);
  734.         
  735.         /* we get wireframe */
  736.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  737.         /* we get list of gallery */
  738.         $gallery $dem->getRepository(Gallery::class)->getGallery($galleryId);
  739.         $galleryItemList $dem->getRepository(GalleryItem::class)->getGalleryItemList($galleryId);
  740.         //print('<br>qqw gallery: ');
  741.         //\Doctrine\Common\Util\Debug::dump($galleryItemList);
  742.     
  743.         /* we render data */
  744.         return $this->render('webGallery.html.twig',
  745.                 array(  'headerData' => $this -> getPageHeader($request),
  746.                         'menu' => $this -> adminMenu($request),
  747.                         'mainMenu' => $this -> adminMainMenu($request),
  748.                         'web' => $web,
  749.                         'user' => $user,
  750.                         'userDirs' => $userDirs,
  751.                         'wireFrame' => $wireFrame,
  752.                         'webPageHeader' => $webPageHeader,
  753.                         'webPageFooter' => $webPageFooter,
  754.                         'webMenuMain' => $webMenuMain,
  755.                         'webMenuItemList' => $webMenuItemList,
  756.                         'webMenuTop' => $webMenuTop,                        
  757.                         'webMenuTopItemList' => $webMenuTopItemList,                         
  758.                         'gallery' => $gallery,
  759.                         'galleryItemList' => $galleryItemList,
  760.                         'backUrl' => $backUrl,
  761.                 )
  762.                 );
  763.     
  764.     }  
  765.     /**
  766.      * @Route("/webConfig", name="webConfig")
  767.      */
  768.     public function webConfigAction(Request $request)
  769.     {
  770.     
  771.         /* we load session data */
  772.         parent::init($request);
  773.         $session $request->getSession();
  774.     
  775.         /* we load master entity manager */
  776.         $em $this->doctrine->getManager();
  777.         $dem $this->doctrine->getManager('dynamic_em');
  778.          
  779.         $currentUserId $session->get('user')->getUserId();
  780.         $user $em->getRepository(User::class)->getUser($currentUserId);
  781.     
  782.         /* we get current website */
  783.         $web $em->getRepository(Website::class)->getCurrentWebsite($currentUserId);
  784.          
  785.         /* we get css designs */
  786.         $cssDesignCollection $dem->getRepository(CssDesign::class)->getCssDesignList();
  787.         if(count($cssDesignCollection) == 0) {
  788.             print('we create new css file');
  789.             $cssDesign = new CssDesign;
  790.             $cssDesign->setCssDesignName($user->getUserName());
  791.             $cssDesign->setCssDesignFile($user->getUserName().".css");
  792.             /* we persist and save */
  793.             $dem->persist($cssDesign);
  794.             $dem->flush();
  795.             $this->addFlash('notice'$this->translator->trans('module.cssDesigner_created'));
  796.             return $this->redirectToRoute('webConfig');
  797.         }
  798.         
  799.         /* we get wireframes */
  800.         $wireFrameCollection $em->getRepository(WireFrame::class)->getWireFrameListByService(3);
  801.         /* we get languages */
  802.         $langCollection $em->getRepository(Language::class)->getLanguageList();
  803.          
  804.         /* we build form */
  805.         $formBuilder $this->createFormBuilder($web);
  806.     
  807.         $formBuilder->add('websiteName'TextType::class, array(
  808.                 'required' => false,
  809.                 'label' => $this->translator->trans('webpages.name'),
  810.                 'attr' => array('class' => 'text_form''size' => 35'value' => $web->getWebsiteName()),
  811.                 'label_attr' => array('class' => 'form_field_label')
  812.         ));
  813.         /* we add css designs list */
  814.         $cssDesigns = array();
  815.         $selectedCss '';
  816.         foreach($cssDesignCollection as $cssDesign)
  817.         {
  818.             $cssDesignId $cssDesign->getCssDesignId();
  819.             $cssDesigns[$cssDesign->getCssDesignName()] = $cssDesignId;
  820.     
  821.             /* we look for selected css design of the e-shop */
  822.             if($cssDesign->getCssDesignFile() == $web->getWebsiteCss()) {
  823.                 $selectedCss $cssDesign->getCssDesignId();
  824.             }
  825.         }
  826.     
  827.         $formBuilder->add('cssDesignId'ChoiceType::class, array(
  828.                 'choices' => $cssDesigns,
  829.                 'required' => false,
  830.                 'mapped' => false,
  831.                 'multiple' => false,
  832.                 'expanded' => true,
  833.                 'placeholder' => false,
  834.                 'label_attr' => array('class' => 'form_field_label'),
  835.                 'attr' => array('class' => 'form_field_text'),                
  836.                 'data' => $selectedCss
  837.         ));
  838.         
  839.         /* we add wireframe list */
  840.         $wireFrames = array();
  841.         $selectedWireFrame '';
  842.         foreach($wireFrameCollection as $wireFrame)
  843.         {
  844.             $wireFrameId $wireFrame->getWireFrameId();
  845.             $wireFrames[$wireFrame->getWireFrameName()] = $wireFrameId;
  846.         
  847.             /* we look for selected wireframe of the website */
  848.             if($wireFrame->getWireFrameId() == $web->getWireFrameId()) {
  849.                 $selectedWireFrame $wireFrame->getWireFrameId();
  850.             }
  851.         }  
  852.         
  853.         $formBuilder->add('wireFrameId'ChoiceType::class, array(
  854.                 'choices' => $wireFrames,
  855.                 'required' => false,
  856.                 'mapped' => false,
  857.                 'multiple' => false,
  858.                 'expanded' => true,
  859.                 'placeholder' => false,
  860.                 'label_attr' => array('class' => 'form_field_label'),
  861.                 'attr' => array('class' => 'form_field_text'),                
  862.                 'data' => $selectedWireFrame,
  863.         ));        
  864.         /* we add language list */
  865.         $languages = array();
  866.         foreach($langCollection as $lang)
  867.         {
  868.             $langId $lang->getLangId();
  869.             $languages[$lang->getLangName()] = $lang->getLangId();
  870.         }
  871.         $selectedLanguages = array();
  872.         foreach($web->getLanguages() as $lang) {
  873.             $selectedLanguages[] = $lang->getLangId();
  874.         }
  875.          
  876.         $formBuilder->add('languages'ChoiceType::class, array(
  877.                 'choices' => $languages,
  878.                 'label' => $this->translator->trans('system.languages'),
  879.                 'required' => false,
  880.                 'mapped' => false,
  881.                 'multiple' => true,
  882.                 'expanded' => true,
  883.                 'label_attr' => array('class' => 'form_field_label'),
  884.                 'attr' => array('class' => 'form_field_text'),
  885.                 'data' => $selectedLanguages
  886.         ));  
  887.         
  888.         $formBuilder->add('preferredLanguageId'ChoiceType::class, array(
  889.                 'choices' => $languages,
  890.                 'label' => $this->translator->trans('system.language_preferred'),
  891.                 'required' => true,
  892.                 'mapped' => false,
  893.                 'multiple' => false,
  894.                 'placeholder' => false,
  895.                 'expanded' => true,
  896.                 'label_attr' => array('class' => 'form_field_label'),
  897.                 'attr' => array('class' => 'form_field_text'),
  898.                 'data' => $web->getPreferredLanguageId()
  899.         ));             
  900.          
  901.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('form.send'),
  902.                 'attr' => array('class' => 'butt_big')));
  903.     
  904.         $form $formBuilder->getForm();
  905.         $form->handleRequest($request);
  906.     
  907.         if ($request->getMethod() == 'POST') {
  908.             //$form->bindRequest($request);
  909.              
  910.             if ($form->isValid()) {
  911.                 $formData $form->getData();
  912.     
  913.                 /* we load eshop data from form into object */
  914.                 $web->setWebsiteName($formData->getWebsiteName());
  915.                 /* we remove old language associations */
  916.                 foreach($web->getLanguages() as $lang) {
  917.                     $web->removeLanguage($lang);
  918.                 }
  919.                     
  920.                 /* we load web languages */
  921.                 if(!empty($form['languages']->getData())) {
  922.                     foreach($form['languages']->getData() as $langId) {
  923.                         $addLang $em->getRepository(Language::class)->getLanguage($langId);
  924.                         $web->addLanguage($addLang);
  925.                     }
  926.                 }
  927.                 
  928.                 /* we set default language */
  929.                 $web->setPreferredLanguageId($form['preferredLanguageId']->getData());
  930.                 /* we set css design */
  931.                 $cssDesign $dem->getRepository(CssDesign::class)->getCssDesign($form['cssDesignId']->getData());
  932.                 $web->setWebsiteCss($cssDesign->getCssDesignFile());
  933.                 /* wireframe setting */
  934.                 $web->setWireFrameId($form['wireFrameId']->getData());
  935.                 /*
  936.                  print('<br>qqw user exists: ');
  937.                  \Doctrine\Common\Util\Debug::dump($user);
  938.                  */
  939.     
  940.                 /* we persist and save user */
  941.                 $em->persist($web);
  942.                 $em->flush();
  943.     
  944.                 $this->addFlash('notice''Website was updated.');
  945.                 return $this->redirectToRoute('webConfig');
  946.     
  947.             }
  948.              
  949.         }
  950.     
  951.         /* we render data */
  952.         return $this->render('webConfig.html.twig',
  953.                 array(  'headerData' => $this -> getPageHeader($request),
  954.                         'form' => $formBuilder->getForm()->createView(),
  955.                         'menu' => $this -> adminMenu($request),
  956.                         'mainMenu' => $this -> adminMainMenu($request),
  957.                         'user' => $user,
  958.                 )
  959.                 );
  960.     
  961.     }      
  962.     /**
  963.      * @Route("/webPageNew", name="webPageNew")
  964.      */
  965.     public function webPageNewAction(Request $request)
  966.     {
  967.     
  968.         /* we load session data */
  969.         parent::init($request);
  970.     
  971.         $session $request->getSession();
  972.     
  973.         /* we load master entity manager */
  974.         $em $this->doctrine->getManager();
  975.         $dem $this->doctrine->getManager('dynamic_em');
  976.         
  977.         $currentUserId $session->get('user')->getUserId();
  978.         $user $em->getRepository(User::class)->getUser($currentUserId);
  979.         
  980.         /* we get current website */
  981.         $web $em->getRepository(Website::class)->getCurrentWebsite($currentUserId);
  982.         /* we build login form */
  983.         $webPage = new WebPage;
  984.         $formBuilder $this->createFormBuilder($webPage);
  985.     
  986.         $formBuilder->add('webPageName'TextType::class, array(
  987.                 'required' => true,
  988.                 'label' => $this->translator->trans('webpages.page_title'),
  989.                 'attr' => array('class' => 'text_form''size' => 22),
  990.                 'label_attr' => array('class' => 'form_field_label'),
  991.         ));
  992.       
  993.       /* we add flag if it is eshop page */
  994.       if(!empty($request->query->get('eshopPage'))) {
  995.         $formBuilder->add('eshopPage'HiddenType::class, array(
  996.             'data' => 1,
  997.             'mapped' => false
  998.         ));   
  999.       } else {
  1000.           $formBuilder->add('eshopPage'HiddenType::class, array(
  1001.               'data' => 0,
  1002.               'mapped' => false
  1003.           ));
  1004.       }
  1005.     
  1006.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('form.button.save'),
  1007.                 'attr' => array('class' => 'butt_big')));
  1008.     
  1009.         $form $formBuilder->getForm();
  1010.         $form->handleRequest($request);
  1011.     
  1012.         if ($request->getMethod() == 'POST') {
  1013.     
  1014.             if ($form->isValid()) {
  1015.                 $formData $form->getData();
  1016.                 $webPage->setWebPageName($formData->getWebPageName());
  1017.           
  1018.               if(!empty($form['eshopPage']->getData()) && ($form['eshopPage']->getData()==1)) {
  1019.                   /* we get current eshop */
  1020.                   $eshop $em->getRepository(Eshop::class)->getCurrentEshop($currentUserId);
  1021.                   $webPage->setEshopId($eshop->getEshopId());
  1022.               } else {
  1023.                   $webPage->setWebsiteId($web->getWebsiteId());
  1024.               }
  1025.                 //$webPage->setUserId($session->get('user')->getUserId());
  1026.                 $webPage->setDateInserted(new \DateTime("now"));
  1027.                 $webPage->setDatePublished(new \DateTime("now"));
  1028.                 /* we persist and save */
  1029.                 $dem->persist($webPage);
  1030.                 $dem->flush();
  1031.     
  1032.                 $this->addFlash('notice''New web page was created.');
  1033.     
  1034.                 return $this->redirectToRoute('webPageEdit', array('webPageId' => $webPage->getWebPageId()));
  1035.     
  1036.             }
  1037.              
  1038.         }
  1039.     
  1040.         /* we render data */
  1041.         return $this->render('webPageNew.html.twig',
  1042.                 array(    'form' => $formBuilder->getForm()->createView(),
  1043.                         'headerData' => $this -> getPageHeader($request),
  1044.                         'menu' => $this -> adminMenu($request),
  1045.                         'mainMenu' => $this -> adminMainMenu($request),
  1046.                         'user' => $user,
  1047.                 )
  1048.                 );
  1049.     
  1050.     }
  1051.     public function webCreate(Request $request$webName "Test web")
  1052.     {       
  1053.         /* we load session data */
  1054.         parent::init($request);
  1055.     
  1056.         $session $request->getSession();
  1057.     
  1058.         $em $this->doctrine->getManager();
  1059.         $dem $this->doctrine->getManager('dynamic_em');
  1060.         
  1061.         //print('qqw creating web...');
  1062.         $web = new Website;
  1063.         $web->setWebsiteName($webName);
  1064.         $web->setUserId($session->get('user')->getUserId());
  1065.         // wireframe setting
  1066.         $web->setWireFrameId(1);    
  1067.         // we add language
  1068.         $addLang $em->getRepository(Language::class)->getLanguage(1);
  1069.         $web->addLanguage($addLang);         
  1070.  
  1071.         // we set this web as current one 
  1072.         $em->getRepository(Website::class)->unsetCurrentWebsite($session->get('user')->getUserId());
  1073.         $em->getRepository(Website::class)->setCurrentWebsite($session->get('user')->getUserId(), $web->getWebsiteId());
  1074.         // we persist and save
  1075.         $em->persist($web);
  1076.         $em->flush();
  1077.         
  1078.         // we insert data fixtures
  1079.         $this->webDataFixtures($request);
  1080.         $this->addFlash('notice'$this->translator->trans('web.created'));
  1081.     }      
  1082.     
  1083.     /**
  1084.      * we insert default data into e-shop from basicdemo account
  1085.     */
  1086.     public function webDataFixtures(Request $request)
  1087.     {       
  1088.         /* we load session data */
  1089.         parent::init($request);
  1090.     
  1091.         $session $request->getSession();
  1092.     
  1093.         $em $this->doctrine->getManager();
  1094.         $dem $this->doctrine->getManager('dynamic_em');
  1095.         $demo_em $this->doctrine->getManager('eshop_demo_em');
  1096.         
  1097.         print('qqw web data fixtures...');
  1098.         $userId $session->get('user')->getUserId();
  1099.         /* we get current web */
  1100.         $currentWeb $em->getRepository(Website::class)->getCurrentWebsite($userId);
  1101.          
  1102.         /* we get basicdemo web */
  1103.         $demoUserId 97//demobasic user id
  1104.         $demoweb $em->getRepository(Website::class)->getCurrentWebsite($demoUserId);
  1105.         if(empty($demoweb)) {
  1106.             $this->addFlash('error''Demo base web - No fixture data.');
  1107.             return;
  1108.         }
  1109.         print('<br>qqw current web id: '.$demoweb->getWebsiteId());
  1110.         $demoPagesCollection $demo_em->getRepository(WebPage::class)->getWebPageList();
  1111.         //$cat->setLocale($session->get('lang')->getLangKey());
  1112.         
  1113.         foreach($demoPagesCollection as $demoPage)
  1114.         {
  1115.             $pageId $demoPage->getPageId();
  1116.             print('<br>qqw demo page: '.$pageId);
  1117.             \Doctrine\Common\Util\Debug::dump($demoPage); 
  1118.                 //we update or create web page
  1119.                 $page null;
  1120.                 if(empty($page)) {
  1121.                     $page = new WebPage;
  1122.                 }
  1123.                 $page->setWebPageName($demoPage->getWebPageName());
  1124.                 $page->setWebPageContent($demoPage->getWebPageContent());
  1125.                 $page->setWebsiteId($demoPage->getWebsiteId());
  1126.                 $page->setWebPageType($demoPage->getWebPageType());                
  1127.                 $page->setEshopId($demoPage->getEshopId());
  1128.                 $page->setLocale($demoPage->getLocale());                
  1129.                 $page->setWebPageDescription($demoPage->getWebPageDescription());
  1130.                 $page->setPriority($demoPage->getPriority());                
  1131.                 $page->setImageFile($demoPage->getImageFile());
  1132.                 $page->setSeoTitle($demoPage->getSeoTitle());                
  1133.                 $page->setSeoDescription($demoPage->getSeoDescription());                   
  1134.                 $page->setAuctionHallId($demoPage->getAuctionHallId());                                                    
  1135.                  
  1136.                 // we persist and save page 
  1137.                 $dem->persist($page);
  1138.                 $dem->flush();
  1139.         }   
  1140.     }          
  1141.     /**
  1142.      * @Route("/webPageEdit/{webPageId}", name="webPageEdit")
  1143.      */
  1144.     public function webPageEditAction(Request $request$webPageId)
  1145.     {
  1146.     
  1147.         /* we load session data */
  1148.         parent::init($request);
  1149.         $session $request->getSession();
  1150.         // we check if any user is logged in
  1151.         if(!$this->isLoggedUser($request)) {
  1152.             return $this->redirectToRoute('login');
  1153.         }         
  1154.     
  1155.         /* we load entity managers */
  1156.         $em $this->doctrine->getManager();
  1157.         $dem $this->doctrine->getManager('dynamic_em');
  1158.         $currentUserId $session->get('user')->getUserId();
  1159.         $user $em->getRepository(User::class)->getUser($currentUserId);
  1160.          
  1161.         /* we get current website */
  1162.         $web $em->getRepository(Website::class)->getCurrentWebsite($currentUserId);
  1163.         
  1164.         /* we get web page */
  1165.         $webPage $dem->getRepository(WebPage::class)->getWebPage($webPageId);
  1166.         //print('<br>qqw web page: '.$webPageId);
  1167.         //\Doctrine\Common\Util\Debug::dump($webPage);
  1168.         $webPage->setLocale($session->get('lang')->getLangKey());
  1169.         $dem->refresh($webPage);
  1170.         
  1171.         /*
  1172.         print('<br>qqw web page: '.$webPageId);
  1173.         \Doctrine\Common\Util\Debug::dump($webPage);
  1174.         */     
  1175.         
  1176.         /* we build form */
  1177.         $formBuilder $this->createFormBuilder($webPage);
  1178.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('form.button.save'),
  1179.             'attr' => array('class' => 'butt_big')));
  1180.         $formBuilder->add('webPageName'TextType::class, array(
  1181.                 'required' => true,
  1182.                 'label' => $this->translator->trans('webpages.page_title'),
  1183.                 'attr' => array('class' => 'text_form''size' => 55'value' => $webPage->getWebPageName()),
  1184.                 'label_attr' => array('class' => 'form_field_label')
  1185.         ));
  1186.         /* for eshop - we display page content in various languages */
  1187.         if(!empty($webPage->getEshopId()) && ($webPage->getEshopId() > 0)) {
  1188.             //print("<br>qqw eshop Id: ".$webPage->getEshopId());
  1189.             /* we get current e-shop */
  1190.             $eshop $em->getRepository(Eshop::class)->getEshop($webPage->getEshopId());
  1191.             // webPageContent 
  1192.             foreach($eshop->getLanguages() as $lang) {
  1193.                 if ($lang->getLangKey() == 'en') {
  1194.                     $key 'en_us';
  1195.                 } elseif ($lang->getLangKey() == 'de') {
  1196.                     $key 'de_de';
  1197.                 } elseif ($lang->getLangKey() == 'es') {
  1198.                     $key 'es_es';
  1199.                 } elseif ($lang->getLangKey() == 'cs') {
  1200.                     $key 'cs_cs';
  1201.                 } else {
  1202.                     $key 'en_us';
  1203.                 }
  1204.                 //$webPage->setLocale('cs');
  1205.                 $webPage->setLocale($lang->getLangKey());
  1206.                 $dem->refresh($webPage);
  1207.                 $fieldLabel $this->translator->trans('webpages.page_content').' ['.$lang->getLangKey().']';
  1208.                 $fieldValue $webPage->getWebPageContent();
  1209.                 //print('<br>eshopPage locale: '.$lang->getLangKey());
  1210.                 
  1211.                 $formBuilder->add('webPageContent_'.$lang->getLangKey(), TextareaType::class, array(
  1212.                         'required' => false,
  1213.                         'label' => $fieldLabel,
  1214.                         'attr' => array('class' => 'medium_textarea''size' => 35'value' => $fieldValue),
  1215.                         'label_attr' => array('class' => 'form_field_label'),
  1216.                         'data' => $fieldValue,
  1217.                         'mapped' => false
  1218.                 ));   
  1219.             }
  1220.             // SEO Content
  1221. //            foreach($eshop->getLanguages() as $lang) {
  1222. //
  1223. //                $webPage->setLocale($lang->getLangKey());
  1224. //                $dem->refresh($webPage);
  1225. //
  1226. //                $fieldLabel = $this->translator->trans('webpages.seo_title').' ['.$lang->getLangKey().']';
  1227. //                $fieldValue = $webPage->getSeoTitle();
  1228. //
  1229. //                $formBuilder->add('seoTitle_'.$lang->getLangKey(), TextType::class, array(
  1230. //                        'required' => false,
  1231. //                        'label' => $fieldLabel,
  1232. //                        'attr' => array('class' => 'text_form', 'size' => 55, 'value' => $fieldValue),
  1233. //                        'label_attr' => array('class' => 'form_field_label')
  1234. //                ));
  1235. //
  1236. //                $fieldLabel = $this->translator->trans('webpages.seo_description').' ['.$lang->getLangKey().']';
  1237. //                $fieldValue = $webPage->getSeoDescription();
  1238. //
  1239. //                $formBuilder->add('seoDescription_'.$lang->getLangKey(), TextareaType::class, array(
  1240. //                        'required' => false,
  1241. //                        'label' => $fieldLabel,
  1242. //                        'attr' => array('class' => 'medium_textarea', 'cols' => 55, 'rows' => 4, 'value' => $fieldValue),
  1243. //                        'label_attr' => array('class' => 'form_field_label'),
  1244. //                        'data' => $fieldValue,
  1245. //                ));
  1246. //            }
  1247.             // SEO Content
  1248.             foreach($eshop->getLanguages() as $lang) {
  1249.                 $webPage->setLocale($lang->getLangKey());
  1250.                 $dem->refresh($webPage);
  1251.                 $fieldLabel $this->translator->trans('webpages.seo_title').' ['.$lang->getLangKey().']';
  1252.                 $fieldValue $webPage->getSeoTitle();
  1253.                 $formBuilder->add('seoTitle_'.$lang->getLangKey(), TextType::class, array(
  1254.                     'required' => false,
  1255.                     'label' => $fieldLabel,
  1256.                     'attr' => array('class' => 'text_form''size' => 55'value' => $fieldValue),
  1257.                     'label_attr' => array('class' => 'form_field_label'),
  1258.                     'mapped' => false
  1259.                 ));
  1260.                 //print('<br>eshopPage locale 2: '.$lang->getLangKey());
  1261.                 $fieldLabel $this->translator->trans('webpages.seo_description').' ['.$lang->getLangKey().']';
  1262.                 $fieldValue $webPage->getSeoDescription();
  1263.                 $formBuilder->add('seoDescription_'.$lang->getLangKey(), TextareaType::class, array(
  1264.                     'required' => false,
  1265.                     'label' => $fieldLabel,
  1266.                     'attr' => array('class' => 'text_form''cols' => 55'rows' => 4'value' => $fieldValue),
  1267.                     'label_attr' => array('class' => 'form_field_label'),
  1268.                     'data' => $fieldValue,
  1269.                     'mapped' => false
  1270.                 ));
  1271.             }
  1272.         } else {
  1273.             /* website page  */
  1274.             /*
  1275.             $formBuilder->add('webPageContent', CKEditorType::class, array(
  1276.                     'required' => false,
  1277.                     'label' => $this->translator->trans('webpages.page_content'),
  1278.                     'attr' => array('class' => 'textarea_form', 'cols' => 101, 'rows' => 11),
  1279.                     'label_attr' => array('class' => 'form_textarea_label2'),
  1280.                     'data' => $webPage->getWebPageContent(),
  1281.             ));       
  1282.             */
  1283.             // webPageContent 
  1284.             foreach($web->getLanguages() as $lang) {
  1285.                 $fieldLabel $this->translator->trans('webpages.page_content').' ['.$lang->getLangKey().']';
  1286.                 $webPage->setLocale($lang->getLangKey());
  1287.                 $dem->refresh($webPage);        
  1288.                 $fieldValue $webPage->getWebPageContent();
  1289.                 //CKEditorType::class
  1290.                 //TextareaType 
  1291.                 //print("<br>qqw webpages.page_content: ".$fieldValue);
  1292.                 //@todo - CKEditorType does not render
  1293.                 //CKEditorType::class
  1294.                 $formBuilder->add('webPageContent_'.$lang->getLangKey(), CodeEditorType::class, array(
  1295.                         'required' => false,
  1296.                         'label' => $fieldLabel,
  1297.                         'attr' => array('class' => 'medium_textarea''size' => 35'value' => $fieldValue),
  1298.                         'label_attr' => array('class' => 'form_field_label'),
  1299.                         'data' => $fieldValue,
  1300.                         //'config' => array('toolbar' => 'full'),
  1301.                         'mapped' => false
  1302.                 ));   
  1303.             }
  1304.             // SEO Content
  1305.             foreach($web->getLanguages() as $lang) {
  1306.                 $webPage->setLocale($lang->getLangKey());
  1307.                 $dem->refresh($webPage);        
  1308.                 $fieldLabel $this->translator->trans('webpages.seo_title').' ['.$lang->getLangKey().']';
  1309.                 $fieldValue $webPage->getSeoTitle();
  1310.                 
  1311.                 $formBuilder->add('seoTitle_'.$lang->getLangKey(), TextType::class, array(
  1312.                         'required' => false,
  1313.                         'label' => $fieldLabel,
  1314.                         'attr' => array('class' => 'text_form''size' => 55'value' => $fieldValue),
  1315.                         'label_attr' => array('class' => 'form_field_label'),
  1316.                         'mapped' => false
  1317.                 ));
  1318.                 $fieldLabel $this->translator->trans('webpages.seo_description').' ['.$lang->getLangKey().']';
  1319.                 $fieldValue $webPage->getSeoDescription();
  1320.                 
  1321.                 $formBuilder->add('seoDescription_'.$lang->getLangKey(), TextareaType::class, array(
  1322.                         'required' => false,
  1323.                         'label' => $fieldLabel,
  1324.                         'attr' => array('class' => 'text_form''cols' => 55'rows' => 4'value' => $fieldValue),
  1325.                         'label_attr' => array('class' => 'form_field_label'),
  1326.                         'data' => $fieldValue,
  1327.                         'mapped' => false
  1328.                 ));     
  1329.             } 
  1330.         }      
  1331.          
  1332.         $imageLabel $this->translator->trans('image.main');
  1333.         if(!empty($webPage->getImageFile())) {
  1334.             $imageLabel .= " [ ".$webPage->getImageFile()." ]";
  1335.         }
  1336.         
  1337.         $formBuilder->add('imageFile'FileType::class, array(
  1338.                 'required' => false,
  1339.                 'label' => $imageLabel,
  1340.                 'attr' => array('class' => 'text_form_file''size' => 22'value' => 'vvx'),
  1341.                 'label_attr' => array('class' => 'form_field_label2'),
  1342.                 'mapped' => false
  1343.         ));
  1344.         $formBuilder->add('webPageDescription'TextareaType::class, array(
  1345.                 'required' => false,
  1346.                 'label' => $this->translator->trans('webpages.page_description'),
  1347.                 'attr' => array('class' => 'textarea_form''cols' => 55'rows' => 4'value' => $webPage->getWebPageDescription()),
  1348.                 'label_attr' => array('class' => 'form_textarea_label'),
  1349.                 'data' => $webPage->getWebPageDescription(),
  1350.         ));   
  1351.         if(!empty($webPage->getDatePublished())) {
  1352.             $sDatePublished $webPage->getDatePublished()->format("Y-m-d H:i:s");
  1353.         } else {
  1354.             $sDatePublished '';
  1355.         }
  1356.       
  1357.             $formBuilder->add('datePublished'DateTimeType::class, array(
  1358.                     'required' => false,
  1359.                     'label' => $this->translator->trans('webpages.date_published'),
  1360.                     'attr' => array('class' => 'text_form''size' => 22'value' => $sDatePublished),
  1361.                     'label_attr' => array('class' => 'form_field_label')
  1362.             ));
  1363.         $formBuilder->add('priority'TextType::class, array(
  1364.                 'required' => false,
  1365.                 'label' => $this->translator->trans('system.priority'),
  1366.                 'attr' => array('class' => 'text_form''size' => 5'value' => $webPage->getPriority()),
  1367.                 'label_attr' => array('class' => 'form_field_label')
  1368.         ));
  1369.         /* we add page types list */
  1370.         $webPageTypes = array();
  1371.         $selectedType '';
  1372.         foreach($webPage::PAGETYPE as $key=>$webPageType)
  1373.         {
  1374.             $webPageTypes[$this->translator->trans($key)] = $webPageType;
  1375.         
  1376.             /* we look for selected web page type */
  1377.             if($webPageType == $webPage->getWebPageType()) {
  1378.                 $selectedType $webPageType;
  1379.             }
  1380.         }
  1381. //        print('<br>webPageType selected: '.$selectedType);
  1382. //        print('<br>getWebPageType: '.$webPage->getWebPageType());
  1383.         
  1384.         $formBuilder->add('webPageType'ChoiceType::class, array(
  1385.                 'choices' => $webPageTypes,
  1386.                 'required' => false,
  1387.                 'mapped' => false,
  1388.                 'multiple' => false,
  1389.                 'expanded' => true,
  1390.                 'placeholder' => false,
  1391.                 'data' => $selectedType
  1392.         ));        
  1393.     
  1394.         $formBuilder->add('save2'SubmitType::class, array('label' => $this->translator->trans('form.button.save'),
  1395.                 'attr' => array('class' => 'butt_big')));
  1396.     
  1397.         $form $formBuilder->getForm();
  1398.         $form->handleRequest($request);
  1399.     
  1400.         if ($request->getMethod() == 'POST') {
  1401.     
  1402.             //$form->bindRequest($request);
  1403.             //print("<br>qqw POST");
  1404.     
  1405.             //if ($form->isValid()) {
  1406.                 //print("<br>qqw POST 2");
  1407.                 $formData $form->getData();
  1408.     
  1409.                 /* we load web page data from register form into object */
  1410.                 $webPage->setWebPageName($formData->getWebPageName());
  1411.                 /* for eshop - we save page content in various languages */
  1412.                 if(!empty($webPage->getEshopId()) && ($webPage->getEshopId() > 0)) {
  1413.                     //print("<br>qqw post eshop page ");
  1414.                     /* we get e-shop */
  1415.                     $eshop $em->getRepository(Eshop::class)->getEshop($webPage->getEshopId());
  1416.                     foreach($eshop->getLanguages() as $lang) {
  1417.                         if(!empty($form['webPageContent_' $lang->getLangKey()])) {
  1418.                             $webPage->setWebPageContent($form['webPageContent_' $lang->getLangKey()]->getData());
  1419.                         }
  1420.                         if(!empty($form['seoTitle_' $lang->getLangKey()]->getData())) {
  1421.                             $webPage->setSeoTitle($form['seoTitle_' $lang->getLangKey()]->getData());
  1422.                         }
  1423.                         if(!empty($form['seoDescription_' $lang->getLangKey()]->getData())) {
  1424.                             $webPage->setSeoDescription($form['seoDescription_' $lang->getLangKey()]->getData());
  1425.                         }
  1426.                         $webPage->setLocale($lang->getLangKey());
  1427.                         //$webPage->setTranslatableLocale($key);
  1428.                         //print('<br>persist locale: '.$lang->getLangKey());
  1429.                         //print('<br>page content: '.$form['webPageContent_' . $lang->getLangKey()]->getData());
  1430.                         $dem->persist($webPage);
  1431.                         $dem->flush();
  1432.                     }
  1433. //                    foreach($eshop->getLanguages() as $lang) {
  1434. //                        $webPage->setLocale($lang->getLangKey());
  1435. //
  1436. //                        if(!empty($form['webPageContent_'.$lang->getLangKey()])) {
  1437. //                            $webPage->setWebPageContent($form['webPageContent_'.$lang->getLangKey()]->getData());
  1438. //                        }
  1439. //                        if(!empty($form['seoTitle_'.$lang->getLangKey()])) {
  1440. //                            $webPage->setSeoTitle($form['seoTitle_'.$lang->getLangKey()]->getData());
  1441. //                        }
  1442. //                        if(!empty($form['seoDescription_'.$lang->getLangKey()])) {
  1443. //                            $webPage->setSeoDescription($form['seoDescription_'.$lang->getLangKey()]->getData());
  1444. //                        }
  1445. //
  1446. //                        $dem->persist($webPage);
  1447. //                        $dem->flush();
  1448. //                    }
  1449.                 } else {
  1450.                     //we setup web page page content
  1451.                     //print("<br>qqw post webpages page");
  1452.                     $webPage->setPriority($formData->getPriority());
  1453.                     foreach($web->getLanguages() as $lang) {
  1454.                         $webPage->setWebPageContent($form['webPageContent_'.$lang->getLangKey()]->getData());
  1455.                         $webPage->setSeoTitle($form['seoTitle_'.$lang->getLangKey()]->getData());
  1456.                         $webPage->setSeoDescription($form['seoDescription_'.$lang->getLangKey()]->getData());
  1457.                         $webPage->setLocale($lang->getLangKey());
  1458.                         //$webPage->setTranslatableLocale($key);
  1459.                         print('<br>persist locale: '.$key);
  1460.                         $dem->persist($webPage);
  1461.                         $dem->flush();
  1462.                     }
  1463.                     /* we handle image */
  1464.                     $image1 $request->files->get('form')['imageFile'];
  1465.                     //print('<br>QQW image 1: ');
  1466.                     //\Doctrine\Common\Util\Debug::dump($image1);
  1467.                     
  1468.                     /* we check user folder for user files */
  1469.                     if(!$this->isUserFolder($request)) {
  1470.                         $this->createUserFolder($request);
  1471.                     }
  1472.                     $userDirs $this->getUserFolderPaths($request);
  1473.                     if(!empty($image1)) {
  1474.                       $fileName1 md5(uniqid()).'.'.$image1->guessExtension();
  1475.                       $image1->move($userDirs['images'], $fileName1);
  1476.                       $webPage->setImageFile($fileName1);
  1477.                     }
  1478.                 }
  1479.                 $webPageType $form['webPageType']->getData();
  1480.                 /* if homepage then we unlink old homepage(s) */
  1481.                 if($form['webPageType']->getData() == $webPage::PAGETYPE['PAGETYPE_HOMEPAGE']) {
  1482.                     /* for website */
  1483.                     if(!empty($webPage->getWebsiteId()) && ($webPage->getWebsiteId() > 0)) {
  1484.                         $dem->getRepository(WebPage::class)->emptyPageHome($web->getWebsiteId(), $webPage->getWebPageId());
  1485.                     }            
  1486.                     /* for eshop */
  1487.                     if(!empty($webPage->getEshopId()) && ($webPage->getEshopId() > 0)) {
  1488.                         $dem->getRepository(WebPage::class)->emptyEshopHome($webPage->getEshopId(), $webPage->getWebPageId());
  1489.                     }             
  1490.             
  1491.                 }                
  1492.                 
  1493.                 /* if header then we unlink old page header(s) */
  1494.                 
  1495.                 if($form['webPageType']->getData() == $webPage::PAGETYPE['PAGETYPE_HEADER']) {
  1496.                     // for website 
  1497.                     if(!empty($webPage->getWebsiteId()) && ($webPage->getWebsiteId() > 0)) {
  1498.                         print('<br>------------------------  setting PAGETYPE_HEADER: ');
  1499.                         $dem->getRepository(WebPage::class)->emptyPageHeader($web->getWebsiteId(), $webPage->getWebPageId());
  1500.                     }            
  1501.                     // for eshop 
  1502.                     if(!empty($webPage->getEshopId()) && ($webPage->getEshopId() > 0)) {
  1503.                         $dem->getRepository(WebPage::class)->emptyEshopHeader($webPage->getEshopId(), $webPage->getWebPageId());
  1504.                     }            
  1505.                     
  1506.                 }
  1507.                 
  1508.                 
  1509.                 /* if footer then we unlink old page footer(s) */
  1510.                 if($form['webPageType']->getData() == $webPage::PAGETYPE['PAGETYPE_FOOTER']) {
  1511.                     /* for website */
  1512.                     if(!empty($webPage->getWebsiteId()) && ($webPage->getWebsiteId() > 0)) {
  1513.                         $dem->getRepository(WebPage::class)->emptyPageFooter($web->getWebsiteId(), $webPage->getWebPageId());
  1514.                     }            
  1515.                     /* for eshop */
  1516.                     if(!empty($webPage->getEshopId()) && ($webPage->getEshopId() > 0)) {
  1517.                         $dem->getRepository(WebPage::class)->emptyEshopFooter($webPage->getEshopId(), $webPage->getWebPageId());
  1518.                     }               
  1519.             
  1520.                 }   
  1521.                 /* if leftColumn then we unlink old leftColumn(s) */
  1522.                 if($form['webPageType']->getData() == $webPage::PAGETYPE['PAGETYPE_LEFT_COLUMN']) {
  1523.                     /* for website */
  1524.                     if(!empty($webPage->getWebsiteId()) && ($webPage->getWebsiteId() > 0)) {
  1525.                         $dem->getRepository(WebPage::class)->emptyLeftColumn($web->getWebsiteId(), $webPage->getWebPageId());
  1526.                     }                        
  1527.                 }
  1528.                 //print('<br>---------------------------- qqw PAGETYPE_HEADER: '.$webPage::PAGETYPE['PAGETYPE_HEADER']);
  1529.                 //print('<br>---------------------------- qqw PAGETYPE_COMMON: '.$webPage::PAGETYPE['PAGETYPE_COMMON']);
  1530.                 /* we set page type */
  1531.                 //print('<br>---------------------------- qqw set webPageType: '.(int)$form['webPageType']->getData());
  1532.                 //print('<br>---------------------------- qqw set webPageType 2: '.$webPageType);
  1533.                 
  1534.                 $webPage->setWebPageType($webPageType);
  1535.                 //$this->addFlash('notice', 'webPageType::'.$form['webPageType']->getData());
  1536.                 $webPage->setDatePublished($formData->getDatePublished());
  1537.                  
  1538.                 /* we persist and save */
  1539.                 $dem->persist($webPage);
  1540.                 $dem->flush();
  1541.     
  1542.                 $this->addFlash('notice'$this->translator->trans('webpages.updated'));
  1543.     
  1544.                 return $this->redirectToRoute('webPageEdit', array('webPageId' => $webPage->getWebPageId()));
  1545.     
  1546.             //}
  1547.     
  1548.         }
  1549.         //phpinfo();
  1550.         /* we render data */
  1551.         return $this->render('webPageEdit.html.twig',
  1552.                 array('headerData' => $this -> getPageHeader($request),
  1553.                         'form' => $formBuilder->getForm()->createView(),
  1554.                         'webPage' => $webPage,
  1555.                         'menu' => $this -> adminMenu($request),
  1556.                         'mainMenu' => $this -> adminMainMenu($request),
  1557.                         'user' => $user,
  1558.                 )
  1559.                 );
  1560.     
  1561.     }   
  1562.     /**
  1563.      * @Route("/webPageList", name="webPageList")
  1564.      */
  1565.     public function webPageListAction(Request $request)
  1566.     {
  1567.         /* we load session data */
  1568.         parent::init($request);     
  1569.         $session $request->getSession();
  1570.         
  1571.         /* we load entity managers */
  1572.         $em $this->doctrine->getManager();
  1573.         $dem $this->doctrine->getManager('dynamic_em');
  1574.       
  1575.       /* we get user */ 
  1576.       $userId $session->get('user')->getUserId();
  1577.       $user $em->getRepository(User::class)->getUser($userId);
  1578.       $userDirs $this->getUserFolderPaths($request);
  1579.       
  1580.       /* we get current e-shop */
  1581.       $eshop $em->getRepository(Eshop::class)->getCurrentEshop($userId);
  1582.          
  1583.       //$productList = $dem->getRepository('AppBundle:Product')->getProductList();
  1584.       $webPageList $dem->getRepository(WebPage::class)->getWebPageListByEshop($eshop->getEshopId());
  1585.         
  1586.         //echo $request->attributes->get('_route');
  1587.         //echo $request->getPathInfo();
  1588.         
  1589.         /* we render data */
  1590.         return $this->render('productListEdit.html.php',
  1591.                 array('headerData' => $this -> getPageHeader($request),
  1592.                       'productList' => $productList,
  1593.                       'productThumbs' => $productThumbs,
  1594.                       'userDirs' => $userDirs,
  1595.                       'menu' => $this -> adminMenu($request),
  1596.                         'mainMenu' => $this -> adminMainMenu($request),
  1597.                 )
  1598.                 );
  1599.     
  1600.     }    
  1601.     /**
  1602.      * @Route("/webPageRemove/{webPageId}", name="webPageRemove")
  1603.      */
  1604.     public function webPageRemoveAction(Request $request$webPageId)
  1605.     {
  1606.         /* we load session data */
  1607.         parent::init($request);
  1608.         $session $request->getSession();
  1609.         
  1610.         /* we load entity managers */
  1611.         $em $this->doctrine->getManager();
  1612.         $dem $this->doctrine->getManager('dynamic_em');
  1613.          
  1614.         /* we get user */ 
  1615.         $userId $session->get('user')->getUserId();
  1616.         $user $em->getRepository(User::class)->getUser($userId);
  1617.         
  1618.         /* we get current e-shop */
  1619.         //$eshop = $em->getRepository(Eshop::class)->getCurrentEshop($userId);
  1620.         //$eshopCurrency = $em->getRepository('AppBundle:Currency')->getCurrency($eshop->getPreferredCurrencyId());
  1621.  
  1622.         /* we get webPage */
  1623.         $webPage $dem->getRepository(WebPage::class)->getWebPage($webPageId);
  1624.         /* we remove price levels */
  1625.         //$priceLevelCollection = $dem->getRepository('AppBundle:PriceLevel')->getPriceLevelList();
  1626.         /* we remove categories */
  1627.         //$categoryCollection = $dem->getRepository(Eshop::class)->getCategoryListByEshop($eshop->getEshopId());
  1628.         /* we remove product groups */
  1629.         //$productGroupCollection = $dem->getRepository('AppBundle:ProductGroup')->getProductGroupList();
  1630.         //die('<br>qqw removing product');
  1631.         $dem->remove($webPage);
  1632.         
  1633.         //$em->persist($user);
  1634.         $dem->flush();
  1635.         
  1636.         $this->addFlash('notice''Web page was removed.');
  1637.         
  1638.         return $this->redirectToRoute('productListEdit');
  1639.     }            
  1640.     
  1641.     /**
  1642.      * @Route("/createHeader", name="createHeader")
  1643.      */
  1644.     public function createHeaderAction(Request $request)
  1645.     {
  1646.     
  1647.         /* we load session data */
  1648.         parent::init($request);
  1649.     
  1650.         $session $request->getSession();
  1651.     
  1652.         /* we load entity managers */
  1653.         $em $this->doctrine->getManager();
  1654.         $dem $this->doctrine->getManager('dynamic_em');
  1655.          
  1656.         /* we get current user */
  1657.         $currentUserId $session->get('user')->getUserId();
  1658.         $user $em->getRepository(User::class)->getUser($currentUserId);
  1659.     
  1660.         $webPage = new WebPage;
  1661.         $webPage->setWebPageName("Page Header");    
  1662.     
  1663.       if(!empty($request->query->get('eshopHeader'))) {
  1664.           /* we set current eshop */
  1665.           $currentEshop $em->getRepository(Eshop::class)->getCurrentEshop($currentUserId);
  1666.           $webPage->setEshopId($currentEshop->getEshopId());            
  1667.       } else {
  1668.           /* we set current website */
  1669.           $currentWeb $em->getRepository(Website::class)->getCurrentWebsite($currentUserId);
  1670.           $webPage->setWebsiteId($currentWeb->getWebsiteId());      
  1671.       }
  1672.         $webPage->setWebPageType($webPage::PAGETYPE['PAGETYPE_HEADER']);
  1673.         /* we persist and save */
  1674.         $dem->persist($webPage);
  1675.         $dem->flush();
  1676.         
  1677.         $this->addFlash('notice''Header was created.');
  1678.         
  1679.         return $this->redirectToRoute('webPageEdit', array('webPageId' => $webPage->getWebPageId()));
  1680.     }    
  1681.     
  1682.     /**
  1683.      * @Route("/createFooter", name="createFooter")
  1684.      */
  1685.     public function createFooterAction(Request $request)
  1686.     {
  1687.     
  1688.         /* we load session data */
  1689.         parent::init($request);
  1690.     
  1691.         $session $request->getSession();
  1692.     
  1693.         /* we load entity managers */
  1694.         $em $this->doctrine->getManager();
  1695.         $dem $this->doctrine->getManager('dynamic_em');
  1696.     
  1697.         /* we get current user */
  1698.         $currentUserId $session->get('user')->getUserId();
  1699.         $user $em->getRepository(User::class)->getUser($currentUserId);
  1700.     
  1701.         $webPage = new WebPage;
  1702.         $webPage->setWebPageName("Page Footer");    
  1703.     
  1704.       if(!empty($request->query->get('eshopFooter'))) {
  1705.           /* we set current eshop */
  1706.           $currentEshop $em->getRepository(Eshop::class)->getCurrentEshop($currentUserId);
  1707.           $webPage->setEshopId($currentEshop->getEshopId());            
  1708.       } else {
  1709.           /* we set current website */
  1710.           $currentWeb $em->getRepository(Website::class)->getCurrentWebsite($currentUserId);
  1711.           $webPage->setWebsiteId($currentWeb->getWebsiteId());      
  1712.       }    
  1713.         $webPage->setWebPageType($webPage::PAGETYPE['PAGETYPE_FOOTER']);
  1714.     
  1715.         /* we persist and save */
  1716.         $dem->persist($webPage);
  1717.         $dem->flush();
  1718.          
  1719.         $this->addFlash('notice''Footer was created.');
  1720.          
  1721.         return $this->redirectToRoute('webPageEdit', array('webPageId' => $webPage->getWebPageId()));
  1722.     
  1723.     }      
  1724.     /**
  1725.      * @Route("/web/{webId}/register", name="webRegister")
  1726.      */
  1727.     public function webRegisterAction(Request $request$webId)
  1728.     {
  1729.     
  1730.         /* we load session data */
  1731.         parent::init($request);
  1732.         $session $request->getSession();
  1733.     
  1734.         /* we load entity managers */
  1735.         $em $this->doctrine->getManager();
  1736.         $dem $this->doctrine->getManager('dynamic_em');
  1737.     
  1738.         /* we get current web */
  1739.         $web $em->getRepository(Website::class)->getWebsite($webId);
  1740.          
  1741.         /* we check if web exists */
  1742.         if($web === null) {
  1743.             $this->addFlash('error''Web with tis ID does not exists.');
  1744.             return $this->redirectToRoute('webHome');
  1745.         }
  1746.         /* we load header for the current website */
  1747.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  1748.         /* we load footer for the current website */
  1749.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  1750.          
  1751.         /* we load header for the current website */
  1752.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  1753.         if(!empty($webMenuMain)) {
  1754.            $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  1755.         } else {
  1756.            $webMenuItemList = array();
  1757.         }
  1758.         $user $em->getRepository(User::class)->getUser($web->getUserId());
  1759.         /* we get wireframe */
  1760.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  1761.         /*
  1762.         print('<hr>qqw wireframe: ');
  1763.         \Doctrine\Common\Util\Debug::dump($wireFrame);
  1764.         */
  1765.         $webMenuVertical null;
  1766.         $webMenuVerticalItemList null;
  1767.         /* we load left column - vertical menu for the current website */
  1768.         if($wireFrame->getWireFrameName() == 'Website Classic') {
  1769.             
  1770.             $webMenuVertical $dem->getRepository(WebMenu::class)->getVerticalMenu($webId);
  1771.             if(!empty($webMenuVertical)) {
  1772.                 $webMenuVerticalItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuVertical->getWebMenuId());
  1773.             }
  1774.         }
  1775.         /* we prepare data for the form */
  1776.         if(!empty($request->request->get('form')['company'])) {
  1777.             $company $request->request->get('form')['company'];
  1778.         } else {
  1779.             $company '';
  1780.         }
  1781.         if(!empty($request->request->get('form')['email'])) {
  1782.             $email $request->request->get('form')['email'];
  1783.         } else {
  1784.             $email '';
  1785.         }
  1786.         if(!empty($request->request->get('form')['telefon'])) {
  1787.             $telefon $request->request->get('form')['telefon'];
  1788.         } else {
  1789.             $telefon '';
  1790.         }
  1791.         if(!empty($request->request->get('form')['address'])) {
  1792.             $address $request->request->get('form')['address'];
  1793.         } else {
  1794.             $address '';
  1795.         }
  1796.         if(!empty($request->request->get('form')['username'])) {
  1797.             $username $request->request->get('form')['username'];
  1798.         } else {
  1799.             $username '';
  1800.         }
  1801.         if(!empty($request->request->get('form')['password'])) {
  1802.             $password $request->request->get('form')['password'];
  1803.         } else {
  1804.             $password '';
  1805.         }
  1806.         if(!empty($request->request->get('form')['password_retype'])) {
  1807.             $password_retype $request->request->get('form')['password_retype'];
  1808.         } else {
  1809.             $password_retype '';
  1810.         }       
  1811.         
  1812.         /* we build register form */
  1813.         $formBuilder $this->createFormBuilder();
  1814.         
  1815.         $formBuilder->add('company'TextType::class, array(
  1816.                 'required' => false,
  1817.                 'label' => $this->translator->trans('user.company'),
  1818.                 'attr' => array('class' => 'text_form''size' => 35'value' => $company),
  1819.                 'label_attr' => array('class' => 'form_field_label')
  1820.         ));
  1821.         
  1822.         $formBuilder->add('email'EmailType::class, array(
  1823.                 'required' => true,
  1824.                 'attr' => array('class' => 'text_form''size' => 35'value' => $email),
  1825.                 'label_attr' => array('class' => 'form_field_label_required'),
  1826.         ));
  1827.         
  1828.         $formBuilder->add('telefon'TextType::class, array(
  1829.                 'required' => false,
  1830.                 'label' => $this->translator->trans('user.telephone'),
  1831.                 'attr' => array('class' => 'text_form''size' => 35'value' => $telefon),
  1832.                 'label_attr' => array('class' => 'form_field_label'),
  1833.         ));
  1834.         
  1835.         $formBuilder->add('address'TextareaType::class, array(
  1836.                 'required' => false,
  1837.                 'label' => $this->translator->trans('user.address'),
  1838.                 'attr' => array('class' => 'textarea_form''cols' => 30'rows' => 3'value' => $address),
  1839.                 'label_attr' => array('class' => 'form_textarea_label'),
  1840.         ));
  1841.         
  1842.         $formBuilder->add('username'TextType::class, array(
  1843.                 'required' => true,
  1844.                 'label' => $this->translator->trans('user.username'),
  1845.                 'empty_data'  => '',
  1846.                 'attr' => array('class' => 'text_form''size' => 35'value' => $username),
  1847.                 'label_attr' => array('class' => 'form_field_label_required'),
  1848.         ));
  1849.         
  1850.         $formBuilder->add('password'PasswordType::class, array(
  1851.                 'required' => true,
  1852.                 'label' => $this->translator->trans('user.password'),
  1853.                 'attr' => array('class' => 'text_form''size' => 35'value' => $password),
  1854.                 'label_attr' => array('class' => 'form_field_label_required'),
  1855.         ));
  1856.         
  1857.         $formBuilder->add('password_retype'PasswordType::class, array(
  1858.                 'required' => true,
  1859.                 'label' => $this->translator->trans('user.password_retype'),
  1860.                 'attr' => array('class' => 'text_form''size' => 35'value' => $password_retype),
  1861.                 'label_attr' => array('class' => 'form_field_label_required'),
  1862.         ));      
  1863.         
  1864.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('form.send'),
  1865.                 'attr' => array('class' => 'butt_big')));
  1866.         
  1867.         $form $formBuilder->getForm();
  1868.         
  1869.         $form->handleRequest($request);
  1870.         
  1871.         if ($request->getMethod() == 'POST') {
  1872.         
  1873.             //$form->bindRequest($request);
  1874.             if ($form->isValid()) {
  1875.                 // perform some action, such as save the object to the database
  1876.                 //print('<br>qqw post form 2: ');
  1877.         
  1878.                 /* we check if this contact already exists */
  1879.                 $contactExist $dem->getRepository('AppBundle:Contact')->getContactFromUsername($request->request->get('form')['username']);
  1880.         
  1881.                 /*
  1882.                 print('<br>qqw contact exists: ');
  1883.                 \Doctrine\Common\Util\Debug::dump($contactExist);
  1884.                 */
  1885.                 if($contactExist === null) {
  1886.         
  1887.                     /* we check if the password fields are the same */
  1888.                     $password $request->request->get('form')['password'];
  1889.                     $retypePassword $request->request->get('form')['password_retype'];
  1890.                     if($password != '' && $password == $retypePassword) {
  1891.                         //print('<br>We create new contact');
  1892.                         $contact = new Contact;
  1893.         
  1894.                         $password md5($request->request->get('form')['password']);
  1895.         
  1896.                         /* we load contact data from register form into contact object */
  1897.                         $contact->setCompanyName($request->request->get('form')['company']);
  1898.                         $contact->setContactUserName($request->request->get('form')['username']);
  1899.                         $contact->setEmail($request->request->get('form')['email']);
  1900.                         $contact->setAddress1($request->request->get('form')['address']);
  1901.                         $contact->setContactUserPassword($password);
  1902.                         /*
  1903.                         print('<br>qqw user exists: ');
  1904.                         \Doctrine\Common\Util\Debug::dump($contact);
  1905.                         */
  1906.         
  1907.                         /* we persist and save contact */
  1908.                         $dem->persist($contact);
  1909.                         $dem->flush();
  1910.         
  1911.                         $this->addFlash('notice''New customer account was created.');
  1912.                         
  1913.                         /* we load logged contact into session */
  1914.                         $session $request->getSession();
  1915.                         $session->set('contact'$contact);                     
  1916.                         
  1917.                         return $this->redirectToRoute('webHomeContact', array('webId' => $webId));
  1918.         
  1919.                     }
  1920.                     else {
  1921.                         $this->addFlash('error''Both password fields must be the same.');
  1922.                     }
  1923.         
  1924.                 }
  1925.                 else {
  1926.                     $this->addFlash('error''Account with this username already exists.');
  1927.                 }
  1928.         
  1929.             }
  1930.         
  1931.         }       
  1932.         
  1933.         /* we render data */
  1934.         return $this->render('webRegister.html.php',
  1935.                 array(  'headerData' => $this -> getPageHeader($request),
  1936.                         'form' => $formBuilder->getForm()->createView(),
  1937.                         'menu' => $this -> adminMenu($request),
  1938.                         'mainMenu' => $this -> adminMainMenu($request),
  1939.                         'web' => $web,
  1940.                         'user' => $user,
  1941.                         'wireFrame' => $wireFrame,
  1942.                         'webPageHeader' => $webPageHeader,
  1943.                         'webPageFooter' => $webPageFooter,  
  1944.                         'webMenuVertical' => $webMenuVertical,  
  1945.                         'webMenuVerticalItemList' => $webMenuVerticalItemList,     
  1946.                 )
  1947.                 );
  1948.     
  1949.     }    
  1950.     /**
  1951.      * @Route("/web/{webId}/logout", name="webLogout")
  1952.      */
  1953.     public function webLogoutAction(Request $request$webId) {
  1954.     
  1955.         /* we load session data */
  1956.         parent::init($request);
  1957.     
  1958.         /* we unload logged user session */
  1959.         $session $request->getSession();
  1960.         $session->set('contact'null);
  1961.         $this->addFlash('notice''User was logged out. ');
  1962.     
  1963.         return $this->redirectToRoute('web', array('webId' => $webId));
  1964.     
  1965.     }    
  1966.     /**
  1967.      * @Route("/web/{webId}/login", name="webLogin")
  1968.      */
  1969.     public function webLoginAction(Request $request$webId)
  1970.     {
  1971.     
  1972.         /* we load session data */
  1973.         parent::init($request);
  1974.         $session $request->getSession();
  1975.     
  1976.         /* we load entity managers */
  1977.         $em $this->doctrine->getManager();
  1978.         $dem $this->doctrine->getManager('dynamic_em');
  1979.     
  1980.         /* we get current web */
  1981.         $web $em->getRepository(Website::class)->getWebsite($webId);
  1982.          
  1983.         /* we check if web exists */
  1984.         if($web === null) {
  1985.             $this->addFlash('error''Web with tis ID does not exists.');
  1986.             return $this->redirectToRoute('webHome');
  1987.         }
  1988.         /* if there is a contact logged in then we redirect to contacts home page */
  1989.         if(!empty($session->get('contact'))) {
  1990.             return $this->redirectToRoute('webHomeContact', array('webId' => $webId));
  1991.         }
  1992.         /* we load header for the current website */
  1993.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  1994.         /* we load footer for the current website */
  1995.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  1996.          
  1997.         /* we load header for the current website */
  1998.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  1999.         if(!empty($webMenuMain)) {
  2000.            $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  2001.         } else {
  2002.            $webMenuItemList = array();
  2003.         }
  2004.         /* we load top menu for the current website */
  2005.         $webMenuTop $dem->getRepository(WebMenu::class)->getTopMenu($webId);
  2006.         if(!empty($webMenuTop)) {
  2007.            $webMenuTopItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuTop->getWebMenuId());
  2008.         } else {
  2009.            $webMenuTopItemList = array();
  2010.         } 
  2011.         $user $em->getRepository(User::class)->getUser($web->getUserId());
  2012.         /* we get wireframe */
  2013.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  2014.         /*
  2015.         print('<hr>qqw wireframe: ');
  2016.         \Doctrine\Common\Util\Debug::dump($wireFrame);
  2017.         */
  2018.         $webMenuVertical null;
  2019.         $webMenuVerticalItemList null;
  2020.         /* we load left column - vertical menu for the current website */
  2021.         if($wireFrame->getWireFrameName() == 'Website Classic') {
  2022.             
  2023.             $webMenuVertical $dem->getRepository(WebMenu::class)->getVerticalMenu($webId);
  2024.             if(!empty($webMenuVertical)) {
  2025.                 $webMenuVerticalItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuVertical->getWebMenuId());
  2026.             }
  2027.         }
  2028.     
  2029.         /* we build login form */
  2030.         $formBuilder $this->createFormBuilder();
  2031.         
  2032.         $formBuilder->add('username'TextType::class, array(
  2033.                 'required' => true,
  2034.                 'attr' => array('class' => 'text_form''size' => 22),
  2035.                 'label_attr' => array('class' => 'form_field_label'),
  2036.         ));
  2037.         
  2038.         $formBuilder->add('password'PasswordType::class, array(
  2039.                 'required' => true,
  2040.                 'label' => $this->translator->trans('user.password'),
  2041.                 'attr' => array('class' => 'text_form''size' => 22),
  2042.                 'label_attr' => array('class' => 'form_field_label'),
  2043.         ));
  2044.         
  2045.         $formBuilder->add('save'SubmitType::class, array('label' => 'Login',
  2046.                 'attr' => array('class' => 'butt_big')));
  2047.         
  2048.         $form $formBuilder->getForm();
  2049.         
  2050.         $form->handleRequest($request);
  2051.         
  2052.         if ($request->getMethod() == 'POST') {
  2053.         
  2054.             //$form->bindRequest($request);
  2055.         
  2056.             if ($form->isValid()) {
  2057.                 // perform some action, such as save the object to the database
  2058.                 /* we check if this username exists */
  2059.                 $em $this->doctrine->getManager();
  2060.         
  2061.                 $userName $request->request->get('form')['username'];
  2062.         
  2063.                 $contactExist $dem->getRepository('AppBundle:Contact')->getContactFromLogin($userName$request->request->get('form')['password']);
  2064.                 /*
  2065.                  print('<br>qqw contact exists: '.$userName.' :: '.$request->request->get('form')['password']);
  2066.                  \Doctrine\Common\Util\Debug::dump($contactExist);
  2067.                  */
  2068.                 if(!empty($contactExist)) {
  2069.         
  2070.                     /* we load logged contact into session */
  2071.                     $session $request->getSession();
  2072.                     $session->set('contact'$contactExist);
  2073.         
  2074.                     /*
  2075.                      print('<hr>we set session contact: ');
  2076.                      \Doctrine\Common\Util\Debug::dump($session->get('contact'));
  2077.                      */
  2078.         
  2079.                     $this->addFlash('notice''Welcome '.$userName.'. You are logged in.');
  2080.         
  2081.                     //return $this->redirectToRoute('eshopHomeContact');
  2082.                     if(isset($request->request->get('form')['returnRoute'])) {
  2083.                         return $this->redirectToRoute($request->request->get('form')['returnRoute'], array('webId' => $webId));
  2084.                     } else {
  2085.                         return $this->redirectToRoute('webHomeContact', array('webId' => $webId));
  2086.                     }
  2087.                 }
  2088.                 else {
  2089.                     $this->addFlash('error''Login error.');
  2090.                 }
  2091.         
  2092.             }
  2093.         
  2094.         }       
  2095.         
  2096.         /* we render data */
  2097.         return $this->render('webLogin.html.twig',
  2098.                 array(  'headerData' => $this -> getPageHeader($request),
  2099.                         'form' => $formBuilder->getForm()->createView(),
  2100.                         'menu' => $this -> adminMenu($request),
  2101.                         'mainMenu' => $this -> adminMainMenu($request),
  2102.                         'web' => $web,
  2103.                         'user' => $user,
  2104.                         'wireFrame' => $wireFrame,
  2105.                         'webPageHeader' => $webPageHeader,
  2106.                         'webPageFooter' => $webPageFooter,  
  2107.                         'webMenuVertical' => $webMenuVertical,  
  2108.                         'webMenuVerticalItemList' => $webMenuVerticalItemList,
  2109.                         'webMenuMain' => $webMenuMain,
  2110.                         'webMenuItemList' => $webMenuItemList,
  2111.                         'webMenuTop' => $webMenuTop,                        
  2112.                         'webMenuTopItemList' => $webMenuTopItemList,  
  2113.                 )
  2114.                 );
  2115.         
  2116.         }    
  2117.         
  2118.         /**
  2119.          * @Route("/web/{webId}/webHomeContact", name="webHomeContact")
  2120.          */
  2121.         public function webHomeContactAction(Request $request$webId) {
  2122.         
  2123.         /* we load session data */
  2124.         parent::init($request);
  2125.         $session $request->getSession();
  2126.     
  2127.         /* we load entity managers */
  2128.         $em $this->doctrine->getManager();
  2129.         $dem $this->doctrine->getManager('dynamic_em');
  2130.     
  2131.         /* we get current web */
  2132.         $web $em->getRepository(Website::class)->getWebsite($webId);
  2133.          
  2134.         /* we check if web exists */
  2135.         if($web === null) {
  2136.             $this->addFlash('error''Web with tis ID does not exists.');
  2137.             return $this->redirectToRoute('webHome');
  2138.         }
  2139.         /* we load header for the current website */
  2140.         $webPageHeader $dem->getRepository(WebPage::class)->getWebPageHeader($webId);
  2141.         /* we load footer for the current website */
  2142.         $webPageFooter $dem->getRepository(WebPage::class)->getWebPageFooter($webId);
  2143.          
  2144.         /* we load header for the current website */
  2145.         $webMenuMain $dem->getRepository(WebMenu::class)->getMainMenu($webId);
  2146.         if(!empty($webMenuMain)) {
  2147.            $webMenuItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuMain->getWebMenuId());
  2148.         } else {
  2149.            $webMenuItemList = array();
  2150.         }
  2151.         $user $em->getRepository(User::class)->getUser($web->getUserId());
  2152.         /* we get wireframe */
  2153.         $wireFrame $em->getRepository(WireFrame::class)->getWireFrame($web->getWireFrameId());
  2154.         /*
  2155.         print('<hr>qqw wireframe: ');
  2156.         \Doctrine\Common\Util\Debug::dump($wireFrame);
  2157.         */
  2158.         $webMenuVertical null;
  2159.         $webMenuVerticalItemList null;
  2160.         /* we load left column - vertical menu for the current website */
  2161.         if($wireFrame->getWireFrameName() == 'Website Classic') {
  2162.             
  2163.             $webMenuVertical $dem->getRepository(WebMenu::class)->getVerticalMenu($webId);
  2164.             if(!empty($webMenuVertical)) {
  2165.                 $webMenuVerticalItemList $dem->getRepository(WebMenuItem::class)->getWebMenuItemList($webMenuVertical->getWebMenuId());
  2166.             }
  2167.  
  2168.         }
  2169.             $contactId $session->get('contact')->getContactId();
  2170.             $contact $dem->getRepository('AppBundle:Contact')->getContact($contactId);
  2171.         //print('<hr>qqw contact: '.$contactId);
  2172.         //\Doctrine\Common\Util\Debug::dump($contact);            
  2173.             /* we render data */
  2174.             return $this->render('webHomeContact.html.php',
  2175.                     array('headerData' => $this -> getPageHeader($request),
  2176.                         'menu' => $this -> adminMenu($request),
  2177.                         'mainMenu' => $this -> adminMainMenu($request),
  2178.                         'web' => $web,
  2179.                         'user' => $user,
  2180.                         'contact' => $contact,
  2181.                         'wireFrame' => $wireFrame,
  2182.                         'webPageHeader' => $webPageHeader,
  2183.                         'webPageFooter' => $webPageFooter,  
  2184.                         'webMenuVertical' => $webMenuVertical,  
  2185.                         'webMenuVerticalItemList' => $webMenuVerticalItemList,
  2186.                     )
  2187.                     );
  2188.         
  2189.     }                
  2190.     
  2191.     public function adminMenu(Request $request)
  2192.     { 
  2193.         $menuItems = array(
  2194.                 => array('link' => 'webpagesAdmin''langKey' => 'webpages.admin''routeName' => 'webpagesAdmin'),
  2195.                 => array('link' => 'webPageNew''langKey' => 'webpages.new_page''routeName' => 'webPageNew'),
  2196.                 => array('link' => 'webnew''langKey' => 'webpages.new_web''routeName' => 'webNew'),
  2197.                 => array('link' => 'webConfig''langKey' => 'webpages.config''routeName' => 'webConfig'),
  2198.         );
  2199.     
  2200.         return $menuItems;
  2201.     }
  2202. }