function index(Application $app, Request $request)
 {
     $this->build(isset($_GET['country']) ? $_GET['country'] : null, isset($_GET['area']) ? $_GET['area'] : null, isset($_GET['venue']) ? $_GET['venue'] : null, $request, $app);
     $vrb = new VenueRepositoryBuilder();
     $vrb->setSite($app['currentSite']);
     $vrb->setIncludeDeleted(false);
     $vrb->setMustHaveLatLng(true);
     $venues = $vrb->fetchAll();
     $this->parameters['venues'] = $venues;
     return $app['twig']->render('site/mapPage.html.twig', $this->parameters);
 }
 public function listJson(Request $request, Application $app)
 {
     $vrb = new VenueRepositoryBuilder();
     $vrb->setSite($app['currentSite']);
     $ourRequest = new \Request($request);
     $vrb->setIncludeDeleted($ourRequest->getGetOrPostBoolean('include_deleted', false));
     $out = array('venues' => array());
     foreach ($vrb->fetchAll() as $venue) {
         $out['venues'][] = array('slug' => $venue->getSlug(), 'slugForURL' => $venue->getSlugForUrl(), 'title' => $venue->getTitle());
     }
     return json_encode($out);
 }
 function index($siteid, Request $request, Application $app)
 {
     $sr = new SiteRepository();
     $site = $sr->loadById($siteid);
     if (!$site) {
         die("404");
     }
     $vrb = new VenueRepositoryBuilder();
     $vrb->setSite($site);
     $venues = $vrb->fetchAll();
     return $app['twig']->render('sysadmin/venuelist/index.html.twig', array('site' => $site, 'venues' => $venues));
 }
 protected function editVenueGetDataIntoParameters(Application $app)
 {
     $this->parameters['areas'] = array();
     $this->parameters['venues'] = array();
     $this->parameters['venueSearchDone'] = false;
     if ($this->parameters['doesCountryHaveAnyNotDeletedAreas']) {
         // Area search
         if ($this->parameters['searchArea']) {
             $arb = new AreaRepositoryBuilder();
             $arb->setIncludeDeleted(false);
             $arb->setIncludeParentLevels(1);
             $arb->setSite($app['currentSite']);
             $arb->setCountry($this->parameters['country']);
             $arb->setFreeTextSearch($this->parameters['searchArea']);
             $this->parameters['areas'] = $arb->fetchAll();
             if (count($this->parameters['areas']) == 1 && !$this->parameters['searchAreaSlug']) {
                 $this->parameters['searchAreaSlug'] = $this->parameters['areas'][0]->getSlug();
                 $this->parameters['searchAreaObject'] = $this->parameters['areas'][0];
             }
             // has user selected a area and is it still in search results? If so select it.
             if (!$this->parameters['searchAreaObject'] && $this->parameters['searchAreaSlug'] && intval($this->parameters['searchAreaSlug'])) {
                 foreach ($this->parameters['areas'] as $area) {
                     if ($area->getSlug() == $this->parameters['searchAreaSlug']) {
                         $this->parameters['searchAreaObject'] = $area;
                     }
                 }
             }
         }
     }
     // If user has not added any search fields. and the event is in a area. let's search by area by default.
     if (!$this->parameters['searchFieldsSubmitted'] && !$this->parameters['searchAreaObject'] && $this->parameters['area']) {
         $this->parameters['searchAreaObject'] = $this->parameters['area'];
         $this->parameters['searchArea'] = $this->parameters['area']->getTitle();
         $this->parameters['searchAreaSlug'] = $this->parameters['area']->getSlug();
     }
     // venue search
     if ($this->parameters['searchAddressCode'] || $this->parameters['searchAddress'] || $this->parameters['searchTitle'] || $this->parameters['searchAreaObject']) {
         $vrb = new VenueRepositoryBuilder();
         $vrb->setSite($app['currentSite']);
         $vrb->setCountry($this->parameters['country']);
         $vrb->setIncludeDeleted(false);
         if ($this->parameters['searchTitle']) {
             $vrb->setFreeTextSearchTitle($this->parameters['searchTitle']);
         }
         if ($this->parameters['searchAddress']) {
             $vrb->setFreeTextSearchAddress($this->parameters['searchAddress']);
         }
         if ($this->parameters['searchAddressCode']) {
             $vrb->setFreeTextSearchAddressCode($this->parameters['searchAddressCode']);
         }
         if ($this->parameters['searchAreaObject']) {
             $vrb->setArea($this->parameters['searchAreaObject']);
         }
         $this->parameters['venues'] = $vrb->fetchAll();
         $this->parameters['venueSearchDone'] = true;
     }
 }
 function infoJson($slug, Request $request, Application $app)
 {
     if (!$this->build($slug, $request, $app)) {
         $app->abort(404, "Country does not exist.");
     }
     $data = array('area' => array('slug' => $this->parameters['area']->getSlug(), 'title' => $this->parameters['area']->getTitle(), 'max_lat' => $this->parameters['area']->getCachedMaxLat(), 'max_lng' => $this->parameters['area']->getCachedMaxLng(), 'min_lat' => $this->parameters['area']->getCachedMinLat(), 'min_lng' => $this->parameters['area']->getCachedMinLng()), 'childAreas' => array(), 'venues' => array());
     foreach ($this->parameters['childAreas'] as $childArea) {
         $data['childAreas'][] = array('slug' => $childArea->getSlug(), 'title' => $childArea->getTitle(), 'max_lat' => $childArea->getCachedMaxLat(), 'max_lng' => $childArea->getCachedMaxLng(), 'min_lat' => $childArea->getCachedMinLat(), 'min_lng' => $childArea->getCachedMinLng());
     }
     if (isset($_GET['includeVenues']) && $_GET['includeVenues']) {
         $vrb = new VenueRepositoryBuilder();
         $vrb->setIncludeDeleted(false);
         $vrb->setSite($app['currentSite']);
         $vrb->setArea($this->parameters['area']);
         foreach ($vrb->fetchAll() as $venue) {
             $data['venues'][$venue->getId()] = array('slug' => $venue->getSlug(), 'title' => $venue->getTitle(), 'lat' => $venue->getLat(), 'lng' => $venue->getLng());
         }
     }
     $response = new Response(json_encode($data));
     $response->headers->set('Content-Type', 'application/json');
     $response->setPublic();
     $response->setMaxAge($app['config']->cacheFeedsInSeconds);
     return $response;
 }
 protected function getVenueSearchData()
 {
     $out = array('searchFieldsSubmitted' => $this->request->request->get('action') == 'searchVenues', 'searchTitle' => $this->request->request->get('searchTitle'), 'searchAddress' => $this->request->request->get('searchAddress'), 'searchArea' => $this->request->request->get('searchArea'), 'searchAreaSlug' => $this->request->request->get('searchAreaSlug'), 'searchAddressCode' => $this->request->request->get('searchAddressCode'), 'searchAreaObject' => null, 'venues' => array(), 'areas' => array(), 'venueSearchDone' => false);
     $countryRepository = new CountryRepository();
     $out['country'] = $countryRepository->loadById($this->draftEvent->getDetailsValue('event.country_id'));
     $areaRepository = new AreaRepository();
     $out['doesCountryHaveAnyNotDeletedAreas'] = $areaRepository->doesCountryHaveAnyNotDeletedAreas($this->site, $out['country']);
     if ($out['doesCountryHaveAnyNotDeletedAreas']) {
         // Area search
         if ($out['searchArea']) {
             $arb = new AreaRepositoryBuilder();
             $arb->setIncludeDeleted(false);
             $arb->setIncludeParentLevels(1);
             $arb->setSite($this->site);
             $arb->setCountry($out['country']);
             $arb->setFreeTextSearch($out['searchArea']);
             $out['areas'] = $arb->fetchAll();
             if (count($out['areas']) == 1 && !$out['searchAreaSlug']) {
                 $out['searchAreaSlug'] = $out['areas'][0]->getSlug();
                 $out['searchAreaObject'] = $out['areas'][0];
             }
             // has user selected a area and is it still in search results? If so select it.
             if (!$out['searchAreaObject'] && $out['searchAreaSlug'] && intval($out['searchAreaSlug'])) {
                 foreach ($out['areas'] as $area) {
                     if ($area->getSlug() == $out['searchAreaSlug']) {
                         $out['searchAreaObject'] = $area;
                     }
                 }
             }
         }
     }
     // If user has not added any search fields. and the event is in a area. let's search by area by default.
     if (!$out['searchFieldsSubmitted'] && !$out['searchAreaObject'] && $this->draftEvent->getDetailsValue('incoming.area.id')) {
         $areaRepository = new AreaRepository();
         $area = $areaRepository->loadById($this->draftEvent->getDetailsValue('incoming.area.id'));
         if ($area) {
             $out['searchAreaObject'] = $area;
             $out['searchArea'] = $area->getTitle();
             $out['searchAreaSlug'] = $area->getSlug();
         }
     }
     if ($out['searchAddressCode'] || $out['searchAddress'] || $out['searchTitle'] || $out['searchAreaObject']) {
         $vrb = new VenueRepositoryBuilder();
         $vrb->setSite($this->site);
         $vrb->setCountry($out['country']);
         $vrb->setIncludeDeleted(false);
         if ($out['searchTitle']) {
             $vrb->setFreeTextSearchTitle($out['searchTitle']);
         }
         if ($out['searchAddress']) {
             $vrb->setFreeTextSearchAddress($out['searchAddress']);
         }
         if ($out['searchAddressCode']) {
             $vrb->setFreeTextSearchAddressCode($out['searchAddressCode']);
         }
         if ($out['searchAreaObject']) {
             $vrb->setArea($out['searchAreaObject']);
         }
         $vrb->setLimit(500);
         $out['venues'] = $vrb->fetchAll();
         $out['venueSearchDone'] = true;
     }
     return $out;
 }