- //Fetch sessions
- $sessions = $doctrine->getRepository(Session::class)->findByDatePeriod($period);
-
- //Init calendar
- $calendar = [];
-
- //Init month
- $month = null;
-
- //Iterate on each day
- foreach($period as $date) {
- //Init day in calendar
- $calendar[$Ymd = $date->format('Ymd')] = [
- 'title' => $date->format('d'),
- 'class' => [],
- 'sessions' => []
- ];
- //Append month for first day of month
- if ($month != $date->format('m')) {
- $month = $date->format('m');
- $calendar[$Ymd]['title'] .= '/'.$month;
- }
- //Deal with today
- if ($date->format('U') == ($today = strtotime('today'))) {
- $calendar[$Ymd]['title'] .= '/'.$month;
- $calendar[$Ymd]['current'] = true;
- $calendar[$Ymd]['class'][] = 'current';
- }
- //Disable passed days
- if ($date->format('U') < $today) {
- $calendar[$Ymd]['disabled'] = true;
- $calendar[$Ymd]['class'][] = 'disabled';
- }
- //Set next month days
- if ($date->format('m') > date('m')) {
- $calendar[$Ymd]['next'] = true;
- $calendar[$Ymd]['class'][] = 'next';
- }
- //Iterate on each session to find the one of the day
- foreach($sessions as $session) {
- if (($sessionYmd = $session->getDate()->format('Ymd')) == $Ymd) {
- //Count number of application
- $count = count($session->getApplications());
-
- //Compute classes
- $class = [];
- if ($session->getApplication()) {
- $class[] = 'granted';
- } elseif ($count == 0) {
- $class[] = 'orphaned';
- } elseif ($count > 1) {
- $class[] = 'disputed';
- } else {
- $class[] = 'pending';
- }
+ //Get textual cities
+ $cities = implode($this->translator->trans(' and '), array_filter(array_merge([implode(', ', array_slice($cities, 0, -1))], array_slice($cities, -1)), 'strlen'));
+
+ //Get textual dances
+ $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% %cities%', ['%dances%' => $dances, '%cities%' => $cities]);
+
+ //Set description
+ //TODO: handle french translation when city start with a A, change à in en !
+ $this->context['description'] = $this->translator->trans('%dances% indoor and outdoor calendar %cities%', ['%dances%' => $dances, '%cities%' => $cities]);
+
+ //Set facebook type
+ //XXX: only valid for home page
+ $this->context['facebook']['metas']['og:type'] = 'website';
+
+ //Render the view
+ return $this->render('@RapsysAir/default/index.html.twig', $this->context, $response);
+ }
+
+ /**
+ * The organizer regulation page
+ *
+ * @desc Display the organizer regulation policy
+ *
+ * @param Request $request The request instance
+ * @return Response The rendered view
+ */
+ public function organizerRegulation(Request $request): Response {
+ //Set page
+ $this->context['title'] = $this->translator->trans('Organizer regulation');
+
+ //Set description
+ $this->context['description'] = $this->translator->trans('Libre Air organizer regulation');
+
+ //Set keywords
+ $this->context['keywords'] = [
+ $this->translator->trans('organizer regulation'),
+ $this->translator->trans('Libre Air')
+ ];
+
+ //Render template
+ $response = $this->render('@RapsysAir/default/organizer_regulation.html.twig', $this->context);
+
+ //Set as cachable
+ $response->setEtag(md5($response->getContent()));
+ $response->setPublic();
+ $response->isNotModified($request);
+
+ //Return response
+ return $response;
+ }
+
+ /**
+ * The terms of service page
+ *
+ * @desc Display the terms of service policy
+ *
+ * @param Request $request The request instance
+ * @return Response The rendered view
+ */
+ public function termsOfService(Request $request): Response {
+ //Set page
+ $this->context['title'] = $this->translator->trans('Terms of service');
+
+ //Set description
+ $this->context['description'] = $this->translator->trans('Libre Air terms of service');
+
+ //Set keywords
+ $this->context['keywords'] = [
+ $this->translator->trans('terms of service'),
+ $this->translator->trans('Libre Air')
+ ];
+
+ //Render template
+ $response = $this->render('@RapsysAir/default/terms_of_service.html.twig', $this->context);
+
+ //Set as cachable
+ $response->setEtag(md5($response->getContent()));
+ $response->setPublic();
+ $response->isNotModified($request);
+
+ //Return response
+ return $response;
+ }
+
+ /**
+ * The frequently asked questions page
+ *
+ * @desc Display the frequently asked questions
+ *
+ * @param Request $request The request instance
+ * @return Response The rendered view
+ */
+ public function frequentlyAskedQuestions(Request $request): Response {
+ //Set page
+ $this->context['title'] = $this->translator->trans('Frequently asked questions');
+
+ //Set description
+ $this->context['description'] = $this->translator->trans('Libre Air frequently asked questions');
+
+ //Set keywords
+ $this->context['keywords'] = [
+ $this->translator->trans('frequently asked questions'),
+ $this->translator->trans('faq'),
+ $this->translator->trans('Libre Air')
+ ];
+
+ //Render template
+ $response = $this->render('@RapsysAir/default/frequently_asked_questions.html.twig', $this->context);
+
+ //Set as cachable
+ $response->setEtag(md5($response->getContent()));
+ $response->setPublic();
+ $response->isNotModified($request);
+
+ //Return response
+ return $response;
+ }
+
+ /**
+ * List all users
+ *
+ * @desc Display all user with a group listed as users
+ *
+ * @param Request $request The request instance
+ *
+ * @return Response The rendered view
+ */
+ public function userIndex(Request $request): Response {
+ //With admin role
+ if ($this->isGranted('ROLE_ADMIN')) {
+ //Set section
+ $section = $this->translator->trans('Libre Air users');
+
+ //Set description
+ $this->context['description'] = $this->translator->trans('Libre Air user list');
+ //Without admin role
+ } else {
+ //Set section
+ $section = $this->translator->trans('Libre Air organizers');
+
+ //Set description
+ $this->context['description'] = $this->translator->trans('Libre Air organizers list');
+ }