src/AppBundle/Controller/NewsController.php line 109

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Controller;
  3. use Pimcore\Controller\FrontendController;
  4. use Pimcore\Model\DataObject\Akcii;
  5. use Pimcore\Model\DataObject\Budni;
  6. use Pimcore\Model\DataObject\Trenery;
  7. use Pimcore\Model\DataObject\Abonement;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Zend\Paginator\Paginator;
  10. class NewsController extends FrontendController
  11. {
  12.     // КОНТРОЛЕР АКЦИЙ
  13.     public function akciiAction(Request $request)
  14.     {
  15.         $actionsList = new Akcii\Listing();
  16.         $val 'cross';
  17.         if(strstr($request->getRequestUri(), 'akcii-fitness-energy')) {
  18.             $val 'fitness';     
  19.         } 
  20.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  21.         $actionsList->setCondition($where_str);
  22.         $actionsList->setOrderKey('dateSort');
  23.         $paginator = new Paginator($actionsList);
  24.         $paginator->setCurrentPageNumber($request->get('page'));
  25.         $paginator->setItemCountPerPage(8);
  26.         $this->view->listCount $actionsList->count();
  27.         $this->view->paginator $paginator;
  28.     }
  29.     public function showAkciiAction(Request $request)
  30.     {   
  31.         $docPath $request->getPathInfo();
  32.         //    "id" is the named parameters in "Static Routes"
  33.         $object Akcii::getByPath($docPath);
  34.         if (!$object instanceof Akcii || !$object->isPublished()) {
  35.         //        this will trigger a 404 error response
  36.             throw $this->createNotFoundException('Invalid request');
  37.         }
  38.         $this->view->Akcii $object;
  39.     }
  40.     // КОНТРОЛЕР БУДНЕЙ
  41.     public function budniAction(Request $request)
  42.     {
  43.         // get a list of news objects and order them by date
  44.         $budniList = new Budni\Listing();
  45.         $val 'cross';
  46.         if(strstr($request->getRequestUri(), 'budni-fitness-energy')) {
  47.             $val 'fitness';     
  48.         } 
  49.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  50.         $budniList->setCondition($where_str);
  51.         $budniList->setOrderKey('dateSort');
  52.         $budniList->setOrder('desc');
  53.         $paginator = new Paginator($budniList);
  54.         $paginator->setCurrentPageNumber($request->get('page'));
  55.         $paginator->setItemCountPerPage(9);
  56.         $this->view->listCount $budniList->count();
  57.         $this->view->paginator $paginator;
  58.     }
  59.     public function showBudniAction(Request $request)
  60.     {   
  61.         $docPath $request->getPathInfo();
  62.         //    "id" is the named parameters in "Static Routes"
  63.         $object Budni::getByPath($docPath);
  64.         if (!$object instanceof Budni || !$object->isPublished()) {
  65.         //        this will trigger a 404 error response
  66.             throw $this->createNotFoundException('Invalid request');
  67.         }
  68.         $this->view->Budni $object;
  69.     }
  70.     // КОНТРОЛЕР ТРЕНЕРОВ
  71.     public function treneryAction(Request $request)
  72.     {
  73.         $treneryList = new Trenery\Listing();
  74.         $val 'cross';
  75.         if(strstr($request->getRequestUri(), 'komanda-fitness-energy')) {
  76.             $val 'fitness';     
  77.         } 
  78.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  79.         $treneryList->setCondition($where_str);
  80.         $treneryList->setOrderKey('dateSort');
  81.         $paginator = new Paginator($treneryList);
  82.         $paginator->setCurrentPageNumber($request->get('page'));
  83.         $paginator->setItemCountPerPage(40);
  84.         $this->view->listCount $treneryList->count();
  85.         $this->view->paginator $paginator;
  86.     }
  87.     public function showTreneryAction(Request $request) {   
  88.         $docPath $request->getPathInfo();
  89.         //    "id" is the named parameters in "Static Routes"
  90.         $object Trenery::getByPath($docPath);
  91.         if (!$object instanceof Trenery || !$object->isPublished()) {
  92.             throw $this->createNotFoundException('Invalid request');
  93.         }
  94.         $this->view->Trenery $object;
  95.     }
  96.     // КОНТРОЛЕР АБОНЕМЕНТОВ
  97.     public function abonementsAction(Request $request)
  98.     {
  99.         $abonementsList = new Abonement\Listing();
  100.         $val 'cross';
  101.         if(strstr($request->getRequestUri(), 'ceny-fitness-energy')) {
  102.             $val 'fitness';     
  103.         } 
  104.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  105.         $abonementsList->setCondition($where_str);
  106.         $abonementsList->setOrderKey('order');
  107.         $abonementsList->setOrder('asc');
  108.         $paginator = new Paginator($abonementsList);
  109.         $paginator->setItemCountPerPage(50);
  110.         $this->view->listCount $abonementsList->count();
  111.         $this->view->paginator $paginator;
  112.     }
  113.     public function showAbonementsAction(Request $request)
  114.     {   
  115.         $docPath $request->getPathInfo();
  116.         $object Abonement::getByPath($docPath);
  117.         $shared_secret '5d131445d03d483aa49356cb45b2e331';
  118.         if (!$object instanceof Abonement || !$object->isPublished()) {
  119.             //  this will trigger a 404 error response
  120.             throw $this->createNotFoundException('Invalid request');
  121.         }
  122.         $service_type $object->getService();
  123.         $name $object->getProduct();
  124.         $club $object->getClub();
  125.         $duration $object->getDuration();
  126.         $price $object->getPrice();
  127.         $data_string $service_type $name $club $duration $price;
  128.         $signature hash_hmac('sha256'$data_string$shared_secret);
  129.         $this->view->signature $signature;
  130.         $this->view->Abonement $object;
  131.     }
  132. }