X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/airbundle/blobdiff_plain/bc62694c7f6cd91a1d9564be415bed8d877c94a5..0986da34a61bfc439c83930abb7162dbaadff851:/Controller/LocationController.php diff --git a/Controller/LocationController.php b/Controller/LocationController.php index 8838d69..6a98a0b 100644 --- a/Controller/LocationController.php +++ b/Controller/LocationController.php @@ -41,14 +41,24 @@ class LocationController extends DefaultController { //Set modified $this->modified = max(array_map(function ($v) { return $v['modified']; }, array_merge($this->context['cities'], $this->context['dances']))); - //Add city multi + //Iterate on each cities foreach($this->context['cities'] as $id => $city) { + //Set coordinates + $coordinates = []; + + //Iterate on each locations + foreach($city['locations'] as $location) { + //Add coordinates + $coordinates[] = [ $location['latitude'], $location['longitude'] ]; + } + //Add city multi - $this->context['cities'][$id]['multimap'] = $this->map->getMultiMap($city['multimap'], $this->modified->getTimestamp(), $city['locations']); + #$this->context['cities'][$id]['multimap'] = $this->map->getMultiMap($city['multimap'], $this->modified->getTimestamp(), $city['locations']); + $this->context['cities'][$id]['multimap'] = $this->image->getMulti($coordinates) + ['caption' => $city['multimap']]; } //With logged user - if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) { + if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { //Set last modified $response->setLastModified(new \DateTime('-1 year')); @@ -74,7 +84,7 @@ class LocationController extends DefaultController { } //Set section - $this->context['title'] = $this->translator->trans('Libre Air cities'); + $this->context['title']['page'] = $this->translator->trans('Libre Air cities'); //Set description $this->context['description'] = $this->translator->trans('Libre Air city list'); @@ -128,7 +138,7 @@ class LocationController extends DefaultController { } //Add calendar - $this->context['calendar'] = $this->doctrine->getRepository(Session::class)->findAllByPeriodAsCalendarArray($this->period, !$this->isGranted('IS_AUTHENTICATED_REMEMBERED'), floatval($latitude), floatval($longitude)); + $this->context['calendar'] = $this->doctrine->getRepository(Session::class)->findAllByPeriodAsCalendarArray($this->period, !$this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED'), floatval($latitude), floatval($longitude)); //Set dances $this->context['dances'] = []; @@ -156,7 +166,7 @@ class LocationController extends DefaultController { $response = new Response(); //With logged user - if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) { + if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { //Set last modified $response->setLastModified(new \DateTime('-1 year')); @@ -181,8 +191,18 @@ class LocationController extends DefaultController { } } + //Set coordinates + $coordinates = []; + + //Iterate on each locations + foreach($this->context['locations'] as $location) { + //Add coordinates + $coordinates[] = [ $location['latitude'], $location['longitude'] ]; + } + //Add multi - $this->context['multimap'] = $this->map->getMultiMap($this->context['city']['multimap'], $this->modified->getTimestamp(), $this->context['locations']); + #$this->context['multimap'] = $this->map->getMultiMap($this->context['city']['multimap'], $this->modified->getTimestamp(), $this->context['locations']); + $this->context['multimap'] = $this->image->getMulti($coordinates) + ['caption' => $this->context['city']['multimap']]; //Set keywords $this->context['keywords'] = [ @@ -205,13 +225,13 @@ class LocationController extends DefaultController { $dances = implode($this->translator->trans(' and '), array_filter(array_merge([implode(', ', array_slice($dances, 0, -1))], array_slice($dances, -1)), 'strlen')); //Set title - $this->context['title'] = $this->translator->trans('%dances% %city%', ['%dances%' => $dances, '%city%' => $this->context['city']['in']]); + $this->context['title']['page'] = $this->translator->trans('%dances% %city%', ['%dances%' => $dances, '%city%' => $this->context['city']['in']]); //Set description $this->context['description'] = $this->translator->trans('%dances% indoor and outdoor calendar %city%', ['%dances%' => $dances, '%city%' => $this->context['city']['in']]); } else { //Set title - $this->context['title'] = $this->translator->trans('Dance %city%', ['%city%' => $this->context['city']['in']]); + $this->context['title']['page'] = $this->translator->trans('Dance %city%', ['%city%' => $this->context['city']['in']]); //Set description $this->context['description'] = $this->translator->trans('Indoor and outdoor dance calendar %city%', ['%city%' => $this->context['city']['in']]); @@ -227,7 +247,7 @@ class LocationController extends DefaultController { /** * List all locations * - * @desc Display all locations + * Display all locations * * @param Request $request The request instance * @@ -244,7 +264,7 @@ class LocationController extends DefaultController { $response = new Response(); //With logged user - if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) { + if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { //Set last modified $response->setLastModified(new \DateTime('-1 year')); @@ -269,11 +289,21 @@ class LocationController extends DefaultController { } } + //Set coordinates + $coordinates = []; + + //Iterate on each locations + foreach($this->context['locations'] as $location) { + //Add coordinates + $coordinates[] = [ $location['latitude'], $location['longitude'] ]; + } + //Add multi map - $this->context['multimap'] = $this->map->getMultiMap($this->translator->trans('Libre Air locations sector map'), $this->modified->getTimestamp(), $this->context['locations']); + #$this->context['multimap'] = $this->map->getMultiMap($this->translator->trans('Libre Air locations sector map'), $this->modified->getTimestamp(), $this->context['locations']); + $this->context['multimap'] = $this->image->getMulti($coordinates) + ['caption' => $this->translator->trans('Libre Air locations sector map')]; //Set title - $this->context['title'] = $this->translator->trans('Libre Air locations'); + $this->context['title']['page'] = $this->translator->trans('Libre Air locations'); //Set description $this->context['description'] = $this->translator->trans('Libre Air location list'); @@ -287,7 +317,7 @@ class LocationController extends DefaultController { ]; //Create location forms for role_admin - if ($this->isGranted('ROLE_ADMIN')) { + if ($this->checker->isGranted('ROLE_ADMIN')) { //Fetch all locations $locations = $this->doctrine->getRepository(Location::class)->findAll(); @@ -329,7 +359,7 @@ class LocationController extends DefaultController { $this->addFlash('notice', $this->translator->trans('Location %id% updated', ['%id%' => $location['id']])); //Redirect to cleanup the form - return $this->redirectToRoute('rapsys_air_location', ['location' => $location['id']]); + return $this->redirectToRoute('rapsysair_location', ['location' => $location['id']]); } //Add form to context @@ -366,7 +396,7 @@ class LocationController extends DefaultController { $this->addFlash('notice', $this->translator->trans('Location created')); //Redirect to cleanup the form - return $this->redirectToRoute('rapsys_air_location', ['location' => $data->getId()]); + return $this->redirectToRoute('rapsysair_location', ['location' => $data->getId()]); } //Add form to context @@ -400,11 +430,11 @@ class LocationController extends DefaultController { //With invalid slug if ($location !== $this->context['location']['slug']) { //Redirect on correctly spelled location - return $this->redirectToRoute('rapsys_air_location_view', ['id' => $this->context['location']['id'], 'location' => $this->context['location']['slug']], Response::HTTP_MOVED_PERMANENTLY); + return $this->redirectToRoute('rapsysair_location_view', ['id' => $this->context['location']['id'], 'location' => $this->context['location']['slug']], Response::HTTP_MOVED_PERMANENTLY); } //Fetch calendar - $this->context['calendar'] = $this->doctrine->getRepository(Session::class)->findAllByPeriodAsCalendarArray($this->period, !$this->isGranted('IS_AUTHENTICATED_REMEMBERED'), $this->context['location']['latitude'], $this->context['location']['longitude']); + $this->context['calendar'] = $this->doctrine->getRepository(Session::class)->findAllByPeriodAsCalendarArray($this->period, !$this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED'), $this->context['location']['latitude'], $this->context['location']['longitude']); //Set dances $this->context['dances'] = []; @@ -426,13 +456,13 @@ class LocationController extends DefaultController { //Set modified //XXX: dance modified is already computed inside calendar modified - $this->modified = max(array_merge([$this->context['location']['updated']], array_map(function ($v) { return $v['modified']; }, array_merge($this->context['calendar'], $this->context['locations'])))); + $this->modified = max(array_merge([$this->context['location']['modified']], array_map(function ($v) { return $v['modified']; }, array_merge($this->context['calendar'], $this->context['locations'])))); //Create response $response = new Response(); //With logged user - if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) { + if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { //Set last modified $response->setLastModified(new \DateTime('-1 year')); @@ -457,8 +487,18 @@ class LocationController extends DefaultController { } } + //Set coordinates + $coordinates = []; + + //Iterate on each locations + foreach($this->context['locations'] as $location) { + //Add coordinates + $coordinates[] = [ $location['latitude'], $location['longitude'] ]; + } + //Add multi map - $this->context['multimap'] = $this->map->getMultiMap($this->context['location']['multimap'], $this->modified->getTimestamp(), $this->context['locations']); + #$this->context['multimap'] = $this->map->getMultiMap($this->context['location']['multimap'], $this->modified->getTimestamp(), $this->context['locations']); + $this->context['multimap'] = $this->image->getMulti($coordinates) + ['caption' => $this->context['location']['multimap']]; //Set keywords $this->context['keywords'] = [ @@ -481,14 +521,14 @@ class LocationController extends DefaultController { $dances = implode($this->translator->trans(' and '), array_filter(array_merge([implode(', ', array_slice($dances, 0, -1))], array_slice($dances, -1)), 'strlen')); //Set title - $this->context['title'] = $this->translator->trans('%dances% %location%', ['%dances%' => $dances, '%location%' => $this->context['location']['atin']]); + $this->context['title']['page'] = $this->translator->trans('%dances% %location%', ['%dances%' => $dances, '%location%' => $this->context['location']['atin']]); //Set description $this->context['description'] = $this->translator->trans('%dances% indoor and outdoor calendar %location%', ['%dances%' => $dances, '%location%' => $this->context['location']['at']]); //Without dances } else { //Set title - $this->context['title'] = $this->translator->trans('Dance %location%', ['%location%' => $this->context['location']['atin']]); + $this->context['title']['page'] = $this->translator->trans('Dance %location%', ['%location%' => $this->context['location']['atin']]); //Set description $this->context['description'] = $this->translator->trans('Indoor and outdoor dance calendar %location%', ['%location%' => $this->context['location']['at']]);