]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/SessionController.php
Cleanup
[airbundle] / Controller / SessionController.php
index c3104a3039dc7717b5394c09cb1f64fa7b883725..e15fef6f9da9fc19feaa628aa39c059c75d1d5d3 100644 (file)
@@ -441,6 +441,17 @@ class SessionController extends DefaultController {
                //Set section
                $section = $this->translator->trans('Sessions');
 
+               //Set description
+               $this->context['description'] = $this->translator->trans('Libre Air session list');
+
+               //Set keywords
+               $this->context['keywords'] = [
+                       $this->translator->trans('sessions'),
+                       $this->translator->trans('session list'),
+                       $this->translator->trans('listing'),
+                       $this->translator->trans('Libre Air')
+               ];
+
                //Set title
                $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
 
@@ -487,7 +498,9 @@ class SessionController extends DefaultController {
                        //Iterate on each day
                        new \DateInterval('P1D'),
                        //End with next sunday and 4 weeks
-                       new \DateTime('Monday this week + 5 week')
+                       new \DateTime(
+                               $this->isGranted('IS_AUTHENTICATED_REMEMBERED')?'Monday this week + 4 week':'Monday this week + 2 week'
+                       )
                );
 
                //Fetch calendar
@@ -496,7 +509,7 @@ class SessionController extends DefaultController {
 
                //Fetch locations
                //XXX: we want to display all active locations anyway
-               $locations = $doctrine->getRepository(Location::class)->fetchTranslatedLocationByDatePeriod($this->translator, $period/*, !$this->isGranted('IS_AUTHENTICATED_REMEMBERED')*/);
+               $locations = $doctrine->getRepository(Location::class)->findTranslatedSortedByPeriod($this->translator, $period);
 
                //Render the view
                return $this->render('@RapsysAir/session/index.html.twig', ['title' => $title, 'section' => $section, 'calendar' => $calendar, 'locations' => $locations]+$context+$this->context);
@@ -524,8 +537,24 @@ class SessionController extends DefaultController {
                //Set section
                $section = $this->translator->trans($session['l_title']);
 
+               //Set localization date formater
+               $intl = new \IntlDateFormatter($request->getLocale(), \IntlDateFormatter::GREGORIAN, \IntlDateFormatter::SHORT);
+
+               //Set description
+               $this->context['description'] = $this->translator->trans('Outdoor Argentine Tango session the %date%', [ '%date%' => $intl->format($session['start']) ]);
+
+               //Set keywords
+               $this->context['keywords'] = [
+                       $this->translator->trans('outdoor'),
+                       $this->translator->trans('Argentine Tango'),
+               ];
+
+               //With granted session
+               if (!empty($session['au_id'])) {
+                       $this->context['keywords'][0] = $session['au_pseudonym'];
+               }
                //Set title
-               $title = $this->translator->trans($this->config['site']['title']).' - '.$section.' - '.$this->translator->trans('Session %id%', ['%id%' => $id]);
+               $title = $this->translator->trans($this->config['site']['title']).' - '.$section.' - '.$this->translator->trans(!empty($session['au_id'])?'Session %id% by %pseudonym%':'Session %id%', ['%id%' => $id, '%pseudonym%' => $session['au_pseudonym']]);
 
                //Init context
                $context = [];
@@ -636,7 +665,12 @@ class SessionController extends DefaultController {
                        ],
                        'snippet' => [
                                'id' => $session['p_id'],
-                               'description' => $session['p_description']
+                               'description' => $session['p_description'],
+                               'class' => $session['p_class'],
+                               'contact' => $session['p_contact'],
+                               'donate' => $session['p_donate'],
+                               'link' => $session['p_link'],
+                               'social' => $session['p_social']
                        ],
                        'applications' => null
                ];
@@ -646,9 +680,8 @@ class SessionController extends DefaultController {
                        $context['session']['application'] = [
                                'user' => [
                                        'id' => $session['au_id'],
-                                       'title' => $session['au_pseudonym'],
-                                       'donation' => $session['au_donation'],
-                                       'site' => $session['au_site']
+                                       'by' => $this->translator->trans('by %pseudonym%', [ '%pseudonym%' => $session['au_pseudonym'] ]),
+                                       'title' => $session['au_pseudonym']
                                ],
                                'id' => $session['a_id'],
                                'title' => $this->translator->trans('Application %id%', [ '%id%' => $session['a_id'] ]),
@@ -701,7 +734,9 @@ class SessionController extends DefaultController {
                        //Iterate on each day
                        new \DateInterval('P1D'),
                        //End with next sunday and 4 weeks
-                       new \DateTime('Monday this week + 5 week')
+                       new \DateTime(
+                               $this->isGranted('IS_AUTHENTICATED_REMEMBERED')?'Monday this week + 4 week':'Monday this week + 2 week'
+                       )
                );
 
                //Fetch locations