Browse Source

refactor to prepare for pagination of objects from the api

Olivier Massot 5 years ago
parent
commit
aab8023e43
28 changed files with 416 additions and 352 deletions
  1. 76 0
      ot_templating/Classes/Domain/Repository/ApiPagedCollection.php
  2. 69 54
      ot_templating/Classes/Domain/Repository/BaseApiRepository.php
  3. 34 47
      ot_templating/Classes/Domain/Repository/DonorRepository.php
  4. 79 92
      ot_templating/Classes/Domain/Repository/EventRepository.php
  5. 45 62
      ot_templating/Classes/Domain/Repository/MemberRepository.php
  6. 38 39
      ot_templating/Classes/Domain/Repository/OrganizationRepository.php
  7. 1 1
      ot_templating/Classes/ViewHelpers/Donors/GetAllViewHelper.php
  8. 1 1
      ot_templating/Classes/ViewHelpers/Events/GetAllViewHelper.php
  9. 1 1
      ot_templating/Classes/ViewHelpers/Events/GetNextViewHelper.php
  10. 2 1
      ot_templating/Classes/ViewHelpers/Members/GetAllCaViewHelper.php
  11. 2 1
      ot_templating/Classes/ViewHelpers/Members/GetAllViewHelper.php
  12. 17 4
      ot_templating/Classes/ViewHelpers/Organizations/GetChildrenViewHelper.php
  13. 1 1
      ot_templating/Resources/Private/Layouts/Classic/Events.html
  14. 6 4
      ot_templating/Resources/Private/Layouts/Classic/Structures.html
  15. 4 4
      ot_templating/Resources/Private/Layouts/Classic/StructuresEvents.html
  16. 1 1
      ot_templating/Resources/Private/Layouts/Modern/Events.html
  17. 2 2
      ot_templating/Resources/Private/Layouts/Modern/Members.html
  18. 3 3
      ot_templating/Resources/Private/Layouts/Modern/MembersCa.html
  19. 4 4
      ot_templating/Resources/Private/Layouts/Modern/Structures.html
  20. 11 11
      ot_templating/Resources/Private/Layouts/Modern/StructuresEvents.html
  21. 3 3
      ot_templating/Resources/Private/Partials/Classic/Donors.html
  22. 3 3
      ot_templating/Resources/Private/Partials/Classic/EventsIndex.html
  23. 3 3
      ot_templating/Resources/Private/Partials/Classic/NextEvents.html
  24. 3 3
      ot_templating/Resources/Private/Partials/Modern/Donors.html
  25. 3 3
      ot_templating/Resources/Private/Partials/Modern/EventsIndex.html
  26. 3 3
      ot_templating/Resources/Private/Partials/Modern/NextEvents.html
  27. 0 1
      ot_templating/Resources/Private/Templates/Page/3Col.html
  28. 1 0
      ot_templating/Resources/Private/Templates/Page/Contact.html

+ 76 - 0
ot_templating/Classes/Domain/Repository/ApiPagedCollection.php

@@ -0,0 +1,76 @@
+<?php
+
+
+namespace Opentalent\OtTemplating\Domain\Repository;
+
+/**
+ * Represents an unserialized api response of 'PagedCollection' type
+ *
+ * @package Opentalent\OtTemplating\Domain\Repository
+ */
+class ApiPagedCollection
+{
+    private $totalItems;
+    private $itemsPerPage;
+    private $currentPage;
+    private $members;
+
+    /**
+     * ApiResponse constructor.
+     * @param int $totalItems
+     * @param int $itemsPerPage
+     * @param int $currentPage
+     * @param array $members
+     */
+    public function __construct(
+        int $totalItems,
+        int $itemsPerPage,
+        int $currentPage,
+        array $members
+    ) {
+        $this->totalItems = $totalItems;
+        $this->itemsPerPage = $itemsPerPage;
+        $this->currentPage = $currentPage;
+        $this->members = $members;
+    }
+
+    /**
+     * @return int
+     */
+    public function getTotalItems() {
+        return $this->totalItems;
+    }
+
+    /**
+     * @return int
+     */
+    public function getItemsPerPage() {
+        return $this->itemsPerPage;
+    }
+
+    /**
+     * @return array
+     */
+    public function getMembers() {
+        return $this->members;
+    }
+
+    /**
+     * @return int
+     */
+    public function getCurrentPage() {
+        return $this->currentPage;
+    }
+
+    /**
+     * @return int
+     */
+    public function getLastPage() {
+        $nb = intdiv($this->getTotalItems(), $this->getItemsPerPage());
+        if ($this->getTotalItems() % $this->getItemsPerPage() != 0) {
+            $nb += 1;
+        }
+        return $nb;
+    }
+
+}

+ 69 - 54
ot_templating/Classes/Domain/Repository/BaseApiRepository.php

@@ -8,6 +8,7 @@ use Opentalent\OtTemplating\Exception\ApiRequestException;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
 use Psr\Log\LoggerAwareTrait;
+use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
 use TYPO3\CMS\Extbase\Persistence\Repository;
 use TYPO3\CMS\Extbase\Persistence\Repository;
 
 
 /**
 /**
@@ -21,61 +22,77 @@ abstract class BaseApiRepository extends Repository implements LoggerAwareInterf
     const BASE_URI = 'https://api.opentalent.fr/api/';
     const BASE_URI = 'https://api.opentalent.fr/api/';
     const HYDRA_TYPE = '';
     const HYDRA_TYPE = '';
     const HTTP_METHOD = 'GET';
     const HTTP_METHOD = 'GET';
-    const DEFAULT_ITEMS_PER_PAGE = 999;
+    const DEFAULT_ITEMS_PER_PAGE = 10;
 
 
     private $client;
     private $client;
     private $context;
     private $context;
 
 
-    public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager) {
+    public function __construct(ObjectManagerInterface $objectManager) {
         parent::__construct($objectManager);
         parent::__construct($objectManager);
         $this->client = new Client(['base_uri' => static::BASE_URI]);
         $this->client = new Client(['base_uri' => static::BASE_URI]);
         $this->context = \TYPO3\CMS\Core\Core\Environment::getContext();
         $this->context = \TYPO3\CMS\Core\Core\Environment::getContext();
     }
     }
 
 
     /**
     /**
-     * Send a request to the API and returns
-     * the result as a Response object
+     * Send a request to the API and
+     * returns the records as an array (members)
      *
      *
      * @param string $uri
      * @param string $uri
      * @param array $params
      * @param array $params
-     * @return ResponseInterface
+     * @return ApiPagedCollection
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    protected function get(string $uri, $params = [])
-    {
-        $uri = $uri . '?_format=json';
-        if(!isset($params['itemsPerPage'])) {
-            $params['itemsPerPage'] = (string)self::DEFAULT_ITEMS_PER_PAGE;
-        }
-        if (!empty($params)) {
-            $uri = $uri . '&' . http_build_query($params);
+    protected function getApiRecords(string $uri, $params = []) {
+        $body = $this->getJson($uri, $params);
+
+        // look up for the current page number
+        $matches = [];
+        preg_match("/.*page=(\d+).*/", $body['@id'], $matches);
+        if (in_array(1, $matches)) {
+            $page = (int)$matches[1];
+        } else {
+            $page = 1;
         }
         }
-        try {
-            if (!$this->context->isProduction()) {
-                $this->logger->info('API Call: ' . $uri);
+
+        // build up the members
+        $members = [];
+        foreach ($body['hydra:member'] as $record) {
+            $instance = $this->memberToObject($record);
+            if ($instance != null) {
+                $members[] = $instance;
             }
             }
-            return $this->client->request(static::HTTP_METHOD, $uri);
-        } catch (GuzzleException $e) {
-            throw ApiRequestException::from_exception($e);
         }
         }
+
+        return new ApiPagedCollection(
+            (int)$body['hydra:totalItems'],
+            (int)$body['hydra:itemsPerPage'],
+            $page,
+            $members
+        );
     }
     }
 
 
     /**
     /**
-     * Send a request to the API and returns
-     * the response's body as a string
+     * -- Needs to be reimplemented in subclasses --
+     * Convert response's members record to an actual Domain's object
+     * @param array $member
+     * @return object
+     */
+    abstract protected function memberToObject(array $member);
+
+    /**
+     * Send a request to the API and
+     * returns the first record (member)
      *
      *
      * @param string $uri
      * @param string $uri
      * @param array $params
      * @param array $params
-     * @return string
+     * @return array
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    protected function getBody(string $uri, $params = [])
-    {
-        try {
-            return (string)$this->get($uri, $params)->getBody();
-        } catch (GuzzleException $e) {
-            throw ApiRequestException::from_exception($e);
-        }
+    protected function getApiFirstRecord(string $uri, $params = []) {
+        $params['page'] = '1';
+        $params['totalItems'] = '1';
+        $collection = $this->getApiRecords($uri, $params);
+        return $collection->getMembers()[0];
     }
     }
 
 
     /**
     /**
@@ -89,50 +106,48 @@ abstract class BaseApiRepository extends Repository implements LoggerAwareInterf
      */
      */
     protected function getJson(string $uri, $params = [])
     protected function getJson(string $uri, $params = [])
     {
     {
-        return json_decode($this->getBody($uri, $params));
+        return json_decode($this->getBody($uri, $params),true);
     }
     }
 
 
     /**
     /**
-     * Send a request to the API and
-     * returns the records as an array (members)
+     * Send a request to the API and returns
+     * the response's body as a string
      *
      *
      * @param string $uri
      * @param string $uri
      * @param array $params
      * @param array $params
-     * @return array
+     * @return string
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    protected function getApiRecords(string $uri, $params = []) {
-        try {
-            $data = $this->getJson($uri, $params);
-        } catch (GuzzleException $e) {
-            throw ApiRequestException::from_exception($e);
-        }
-
-        if($data->{'@type'} == 'hydra:PagedCollection') {
-            $records = $data->{'hydra:member'};
-        } else if ($data->{'@type'} == $this::HYDRA_TYPE) {
-            $records = [$data];
-        } else {
-            throw new ApiRequestException('The API response has an unexpected format');
-        }
-        return $records;
+    protected function getBody(string $uri, $params = [])
+    {
+        return (string)$this->get($uri, $params)->getBody();
     }
     }
 
 
     /**
     /**
-     * Send a request to the API and
-     * returns the first record (member)
+     * Send a request to the API and returns
+     * the result as a Response object
      *
      *
      * @param string $uri
      * @param string $uri
      * @param array $params
      * @param array $params
-     * @return array
+     * @return ResponseInterface
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    protected function getApiFirstRecord(string $uri, $params = []) {
+    protected function get(string $uri, $params = [])
+    {
+        $uri = $uri . '?_format=json';
+        if(!isset($params['itemsPerPage'])) {
+            $params['itemsPerPage'] = (string)self::DEFAULT_ITEMS_PER_PAGE;
+        }
+        if (!empty($params)) {
+            $uri = $uri . '&' . http_build_query($params);
+        }
         try {
         try {
-            $records = $this->getApiRecords($uri, $params);
+            if (!$this->context->isProduction()) {
+                $this->logger->info('API Call: ' . $uri);
+            }
+            return $this->client->request(static::HTTP_METHOD, $uri);
         } catch (GuzzleException $e) {
         } catch (GuzzleException $e) {
             throw ApiRequestException::from_exception($e);
             throw ApiRequestException::from_exception($e);
         }
         }
-        return $records[0];
     }
     }
 }
 }

+ 34 - 47
ot_templating/Classes/Domain/Repository/DonorRepository.php

@@ -10,74 +10,61 @@ class DonorRepository extends BaseApiRepository
     CONST URI = BaseApiRepository::BASE_URI . 'public/donors';
     CONST URI = BaseApiRepository::BASE_URI . 'public/donors';
     const HYDRA_TYPE = 'PortailDonor';
     const HYDRA_TYPE = 'PortailDonor';
 
 
-    /**
-     * Returns a Donor object from an Api record
-     *
-     * @param $record
-     * @return Donor|null
-     */
-    private function donorFromJson($record) {
-        if ($record->{'@type'} != $this::HYDRA_TYPE) {
-            return null;
-        }
-        $donor = new Donor();
-        $a = explode('/', $record->{'@id'});
-        $donor->setId(end($a));
-        $donor->setOrganizationId($record->{'organizationId'});
-        $donor->setName($record->{'name'});
-        $donor->setEmail($record->{'email'});
-        $donor->setTelphone($record->{'telphone'});
-        $donor->setWebsite($record->{'website'});
-        $donor->setWording($record->{'wording'});
-        $donor->setDisplayedOn($record->{'displayedOn'});
-        $donor->setLogo($record->{'logo'});
-
-        return $donor;
-    }
-
-    /**
-     * Returns an array of Donor objects from an array of Api records
-     *
-     * @param $records
-     * @return array
-     */
-    private function donorsFromJson($records) {
-        $donors = [];
-        foreach ($records as $record) {
-            $donors[] = $this->donorFromJson($record);
-        }
-        return $donors;
-    }
-
     /**
     /**
      * Get the donors of the organization
      * Get the donors of the organization
      *
      *
      * @param int $organizationId The id of the organization
      * @param int $organizationId The id of the organization
-     * @return array              Donors
+     * @param int $page
+     * @return ApiPagedCollection              Donors
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    public function findByOrganizationId(int $organizationId) {
+    public function findByOrganizationId(int $organizationId, $page = 1) {
         $params = [];
         $params = [];
         $params['organizationId'] = $organizationId;
         $params['organizationId'] = $organizationId;
+        $params['page'] = $page;
 
 
-        $records = $this->getApiRecords($this::URI, $params);
-        return $this->donorsFromJson($records);
+        return $this->getApiRecords($this::URI, $params);
     }
     }
 
 
     /**
     /**
      * Get the donors of the organization's parents
      * Get the donors of the organization's parents
      *
      *
      * @param int $organizationId The id of the organization
      * @param int $organizationId The id of the organization
-     * @return array              Donors
+     * @param int $page
+     * @return ApiPagedCollection              Donors
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    public function findParentsByOrganizationId(int $organizationId) {
+    public function findParentsByOrganizationId(int $organizationId, $page = 1) {
         $params = [];
         $params = [];
         $params['organizationId'] = $organizationId;
         $params['organizationId'] = $organizationId;
         $params['parent'] = 1;
         $params['parent'] = 1;
+        $params['page'] = $page;
 
 
-        $records = $this->getApiRecords($this::URI, $params);
-        return $this->donorsFromJson($records);
+        return $this->getApiRecords($this::URI, $params);
     }
     }
 
 
+    /**
+     * Returns a Donor object from an Api record
+     *
+     * @param $record
+     * @return Donor|null
+     */
+    protected function memberToObject(array $record) {
+        if ($record['@type'] != $this::HYDRA_TYPE) {
+            return null;
+        }
+        $donor = new Donor();
+        $a = explode('/', $record['@id']);
+        $donor->setId(end($a));
+        $donor->setOrganizationId($record['organizationId']);
+        $donor->setName($record['name']);
+        $donor->setEmail($record['email']);
+        $donor->setTelphone($record['telphone']);
+        $donor->setWebsite($record['website']);
+        $donor->setWording($record['wording']);
+        $donor->setDisplayedOn($record['displayedOn']);
+        $donor->setLogo($record['logo']);
+
+        return $donor;
+    }
 }
 }

+ 79 - 92
ot_templating/Classes/Domain/Repository/EventRepository.php

@@ -12,100 +12,37 @@ class EventRepository extends BaseApiRepository
     CONST URI = BaseApiRepository::BASE_URI . 'public/events';
     CONST URI = BaseApiRepository::BASE_URI . 'public/events';
     const HYDRA_TYPE = 'PortailEvent';
     const HYDRA_TYPE = 'PortailEvent';
 
 
-    /**
-     * Returns an Event object from an Api record
-     * @param array $record A record as returned by $this->getApiRecords
-     * @return Event|null
-     * @throws Exception
-     */
-    private function eventFromJson($record) {
-        if ($record->{'@type'} != $this::HYDRA_TYPE) {
-            return null;
-        }
-        $event = new Event();
-        $a = explode('/', $record->{'@id'});
-        $event->setId(end($a));
-        $event->setOrganizationId($record->{'organizationId'});
-        $event->setSubdomain($record->{'subDomain'});
-        $event->setName($record->{'name'});
-        $event->setDescription($record->{'description'});
-        $event->setUrl($record->{'url'});
-        $event->setRule($record->{'rule'});
-        $dateStart = new \DateTime($record->{'datetimeStart'});
-        $dateStart->setTimezone(new \DateTimeZone('Europe/Paris'));
-        $event->setDatetimeStart($dateStart);
-        $dateEnd = new \DateTime($record->{'datetimeStart'});
-        $dateEnd->setTimezone(new \DateTimeZone('Europe/Paris'));
-        $event->setDatetimeEnd(new \DateTime($record->{'datetimeEnd'}, new DateTimeZone("Europe/Paris")));
-        $event->setDates($record->{'dates'});
-        $event->setPlacename($record->{'placeName'});
-        $event->setPlaceDescription($record->{'placeDescription'});
-        $event->setPlaceFloorSize($record->{'placeFloorSize'});
-        $event->setPlaceCapacity($record->{'placeCapacity'});
-        $event->setCity($record->{'city'});
-        $event->setPostalCode($record->{'postalCode'});
-        $event->setStreetAddress($record->{'streetAddress'});
-        $event->setLongitude($record->{'longitude'});
-        $event->setLatitude($record->{'latitude'});
-        $event->setRoomName($record->{'roomName'});
-        $event->setRoomDescription($record->{'roomDescription'});
-        $event->setRoomLocalisation($record->{'roomLocalisation'});
-        $event->setRoomCapacity($record->{'roomCapacity'});
-        $event->setRoomFloorSize($record->{'roomFloorSize'});
-        $event->setZupId($record->{'zupId'});
-        $event->setDeepLink($record->{'deepLink'});
-        $event->setImage($record->{'image'});
-        $event->setPriceMini($record->{'priceMini'});
-        $event->setMeetingSchedule($record->{'meetingSchedule'});
-        $event->setApi($record->{'api'});
-        $event->setParentName($record->{'parentName'});
-        $event->setParentSubdomain($record->{'parentSubDomain'});
-        return $event;
-    }
-
-    /**
-     * Returns an array of Event objects from an array of Api records
-     *
-     * @param array $records An array of records as returned by $this->getApiRecords
-     * @return array
-     * @throws Exception
-     */
-    private function eventsFromJson($records) {
-        $events = [];
-        foreach ($records as $record) {
-            $events[] = $this->eventFromJson($record);
-        }
-        return $events;
-    }
-
     /**
     /**
      * Get the event matching the given id
      * Get the event matching the given id
      *
      *
      * @param int $id The id of the event
      * @param int $id The id of the event
-     * @return Event         Event
+     * @return array Event
      * @throws ApiRequestException
      * @throws ApiRequestException
-     * @throws Exception
      */
      */
-    public function findById($id) {
+    public function findById(int $id) {
         $params = [];
         $params = [];
-        $record = $this->getApiFirstRecord($this::URI . '/' . $id, $params);
-        return $this->eventFromJson($record);
+        return $this->getApiFirstRecord($this::URI . '/' . $id, $params);
     }
     }
 
 
     /**
     /**
      * Get the events of the organization
      * Get the events of the organization
      *
      *
      * @param int $organizationId The id of the organization
      * @param int $organizationId The id of the organization
-     * @param \Datetime $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
-     * @param \Datetime $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
+     * @param null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
+     * @param null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
      * @param int $limit Limit the number of results returned (-1 to disable the limitation)
      * @param int $limit Limit the number of results returned (-1 to disable the limitation)
-     * @return array Events
+     * @param int $page
+     * @return ApiPagedCollection Events
      * @throws ApiRequestException
      * @throws ApiRequestException
-     * @throws Exception
      */
      */
-    public function findByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
+    public function findByOrganizationId(int $organizationId,
+                                         $fromDate = null,
+                                         $toDate = null,
+                                         $limit = -1,
+                                         $page = 1) {
         $params = [];
         $params = [];
         $params['organizationId'] = $organizationId;
         $params['organizationId'] = $organizationId;
+        $params['page'] = $page;
 
 
         if ($limit > 0) {
         if ($limit > 0) {
             $params['itemsPerPage'] = $limit;
             $params['itemsPerPage'] = $limit;
@@ -119,24 +56,28 @@ class EventRepository extends BaseApiRepository
         }
         }
         $params['filter[order][0][datetimeEnd]'] = 'ASC';
         $params['filter[order][0][datetimeEnd]'] = 'ASC';
 
 
-        $records = $this->getApiRecords($this::URI, $params);
-        return $this->eventsFromJson($records);
+        return $this->getApiRecords($this::URI, $params);
     }
     }
 
 
     /**
     /**
      * Get the events of the organization's parents
      * Get the events of the organization's parents
      *
      *
      * @param int $organizationId The id of the organization
      * @param int $organizationId The id of the organization
-     * @param \Datetime $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
-     * @param \Datetime $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
+     * @param null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
+     * @param null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
      * @param int $limit Limit the number of results returned (-1 to disable the limitation)
      * @param int $limit Limit the number of results returned (-1 to disable the limitation)
-     * @return array                        Events
+     * @param int $page
+     * @return ApiPagedCollection Events
      * @throws ApiRequestException
      * @throws ApiRequestException
-     * @throws Exception
      */
      */
-    public function findParentsByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
+    public function findParentsByOrganizationId(int $organizationId,
+                                                $fromDate = null,
+                                                $toDate = null,
+                                                $limit = -1,
+                                                $page = 1) {
         $params = [];
         $params = [];
         $params['organizationId'] = $organizationId;
         $params['organizationId'] = $organizationId;
+        $params['page'] = $page;
 
 
         if ($limit > 0) {
         if ($limit > 0) {
             $params['itemsPerPage'] = $limit;
             $params['itemsPerPage'] = $limit;
@@ -152,8 +93,7 @@ class EventRepository extends BaseApiRepository
 
 
         $params['parent'] = '1';
         $params['parent'] = '1';
 
 
-        $records = $this->getApiRecords($this::URI, $params);
-        return $this->eventsFromJson($records);
+        return $this->getApiRecords($this::URI, $params);
     }
     }
 
 
     /**
     /**
@@ -163,9 +103,8 @@ class EventRepository extends BaseApiRepository
      * @param \Datetime|null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
      * @param \Datetime|null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
      * @param \Datetime|null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
      * @param \Datetime|null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
      * @param int $limit Limit the number of results returned (-1 to disable the limitation)
      * @param int $limit Limit the number of results returned (-1 to disable the limitation)
-     * @return array                        Events
+     * @return ApiPagedCollection Events
      * @throws ApiRequestException
      * @throws ApiRequestException
-     * @throws Exception
      */
      */
     public function findChildrenByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
     public function findChildrenByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
         $params = [];
         $params = [];
@@ -185,8 +124,7 @@ class EventRepository extends BaseApiRepository
 
 
         $params['children'] = '1';
         $params['children'] = '1';
 
 
-        $records = $this->getApiRecords($this::URI, $params);
-        return $this->eventsFromJson($records);
+        return $this->getApiRecords($this::URI, $params);
     }
     }
 
 
     /**
     /**
@@ -194,7 +132,7 @@ class EventRepository extends BaseApiRepository
      *
      *
      * @param int $organizationId The id of the organization
      * @param int $organizationId The id of the organization
      * @param array $searchParams Search arguments
      * @param array $searchParams Search arguments
-     * @return array                        Events
+     * @return ApiPagedCollection                        Events
      * @throws ApiRequestException
      * @throws ApiRequestException
      * @throws Exception
      * @throws Exception
      */
      */
@@ -204,8 +142,57 @@ class EventRepository extends BaseApiRepository
         $params['filter[order][0][datetimeEnd]'] = 'ASC';
         $params['filter[order][0][datetimeEnd]'] = 'ASC';
         $params = array_merge($params, $searchParams);
         $params = array_merge($params, $searchParams);
 
 
-        $records = $this->getApiRecords($this::URI, $params);
-        return $this->eventsFromJson($records);
+        return $this->getApiRecords($this::URI, $params);
     }
     }
 
 
+    /**
+     * Returns an Event object from an Api record
+     * @param array $record A record as returned by $this->getApiRecords
+     * @return Event|null
+     * @throws Exception
+     */
+    protected function memberToObject(array $record) {
+        if ($record['@type'] != $this::HYDRA_TYPE) {
+            return null;
+        }
+        $event = new Event();
+        $a = explode('/', $record['@id']);
+        $event->setId(end($a));
+        $event->setOrganizationId($record['organizationId']);
+        $event->setSubdomain($record['subDomain']);
+        $event->setName($record['name']);
+        $event->setDescription($record['description']);
+        $event->setUrl($record['url']);
+        $event->setRule($record['rule']);
+        $dateStart = new \DateTime($record['datetimeStart']);
+        $dateStart->setTimezone(new \DateTimeZone('Europe/Paris'));
+        $event->setDatetimeStart($dateStart);
+        $dateEnd = new \DateTime($record['datetimeStart']);
+        $dateEnd->setTimezone(new \DateTimeZone('Europe/Paris'));
+        $event->setDatetimeEnd(new \DateTime($record['datetimeEnd'], new DateTimeZone("Europe/Paris")));
+        $event->setDates($record['dates']);
+        $event->setPlacename($record['placeName']);
+        $event->setPlaceDescription($record['placeDescription']);
+        $event->setPlaceFloorSize($record['placeFloorSize']);
+        $event->setPlaceCapacity($record['placeCapacity']);
+        $event->setCity($record['city']);
+        $event->setPostalCode($record['postalCode']);
+        $event->setStreetAddress($record['streetAddress']);
+        $event->setLongitude($record['longitude']);
+        $event->setLatitude($record['latitude']);
+        $event->setRoomName($record['roomName']);
+        $event->setRoomDescription($record['roomDescription']);
+        $event->setRoomLocalisation($record['roomLocalisation']);
+        $event->setRoomCapacity($record['roomCapacity']);
+        $event->setRoomFloorSize($record['roomFloorSize']);
+        $event->setZupId($record['zupId']);
+        $event->setDeepLink($record['deepLink']);
+        $event->setImage($record['image']);
+        $event->setPriceMini($record['priceMini']);
+        $event->setMeetingSchedule($record['meetingSchedule']);
+        $event->setApi($record['api']);
+        $event->setParentName($record['parentName']);
+        $event->setParentSubdomain($record['parentSubDomain']);
+        return $event;
+    }
 }
 }

+ 45 - 62
ot_templating/Classes/Domain/Repository/MemberRepository.php

@@ -14,6 +14,28 @@ class MemberRepository extends BaseApiRepository
     const HYDRA_TYPE = 'PortailMemberBySpeciality';
     const HYDRA_TYPE = 'PortailMemberBySpeciality';
     const HYDRA_TYPE_CA = 'PortailMemberByRole';
     const HYDRA_TYPE_CA = 'PortailMemberByRole';
 
 
+    /**
+     * Get the members of the organization
+     * If $only_ca is true, returns only the members onf the CA
+     *
+     * @param int $organizationId The id of the organization
+     * @param bool $only_ca If true, returns the CA members instead of all the members
+     * @return ApiPagedCollection              Members
+     * @throws ApiRequestException
+     */
+    public function findByOrganizationId(int $organizationId,
+                                         $only_ca = false) {
+        $params = [];
+        $params['filter[where][organizationId]'] = $organizationId;
+        $params['itemsPerPage'] = '200';
+
+        if ($only_ca) {
+            return $this->getApiRecords($this::URI_CA, $params);
+        } else {
+            return $this->getApiRecords($this::URI, $params);
+        }
+    }
+
     /**
     /**
      * Returns a Member object from an Api record
      * Returns a Member object from an Api record
      *
      *
@@ -21,77 +43,38 @@ class MemberRepository extends BaseApiRepository
      * @return Member|null
      * @return Member|null
      * @throws \Exception
      * @throws \Exception
      */
      */
-    private function memberFromJson($record) {
-        if ($record->{'@type'} != $this::HYDRA_TYPE &&
-            $record->{'@type'} != $this::HYDRA_TYPE_CA) {
+    protected function memberToObject(array $record) {
+        if ($record['@type'] != $this::HYDRA_TYPE &&
+            $record['@type'] != $this::HYDRA_TYPE_CA) {
             return null;
             return null;
         }
         }
         $member = new Member();
         $member = new Member();
-        $a = explode('/', $record->{'@id'});
+        $a = explode('/', $record['@id']);
         $member->setId(end($a));
         $member->setId(end($a));
-        $member->setOrganizationId((int)$record->{'organizationId'});
-        $member->setGender($record->{'gender'});
-        $member->setGivenName($record->{'givenName'});
-        $member->setName($record->{'name'});
-        $dateStart = new \DateTime($record->{'datetimeStart'});
+        $member->setOrganizationId((int)$record['organizationId']);
+        $member->setGender($record['gender']);
+        $member->setGivenName($record['givenName']);
+        $member->setName($record['name']);
+        $dateStart = new \DateTime($record['datetimeStart']);
         $dateStart->setTimezone(new \DateTimeZone('Europe/Paris'));
         $dateStart->setTimezone(new \DateTimeZone('Europe/Paris'));
         $member->setStartDate($dateStart);
         $member->setStartDate($dateStart);
-        $dateEnd = new \DateTime($record->{'datetimeStart'});
+        $dateEnd = new \DateTime($record['datetimeStart']);
         $dateEnd->setTimezone(new \DateTimeZone('Europe/Paris'));
         $dateEnd->setTimezone(new \DateTimeZone('Europe/Paris'));
         $member->setEndDate($dateEnd);
         $member->setEndDate($dateEnd);
-        $member->setInstrumentGroup($record->{'instrumentGroup'});
-        $member->setInstrument($record->{'instrument'});
-        $member->setMission($record->{'mission'});
-        $member->setPersonId((int)$record->{'personId'});
-        $member->setImage($record->{'image'});
-        $member->setAdressCity($record->{'addressCity'});
-        $member->setStreetAdress($record->{'streetAddress'});
-        $member->setStreetAdressSecond($record->{'streetAddressSecond'});
-        $member->setStreetAdressThird($record->{'streetAddressThird'});
-        $member->setPostalCode($record->{'postalCode'});
-        $member->setTelphone($record->{'telphone'});
-        $member->setMobilPhone($record->{'mobilPhone'});
-        $member->setEmail($record->{'email'});
+        $member->setInstrumentGroup($record['instrumentGroup']);
+        $member->setInstrument($record['instrument']);
+        $member->setMission($record['mission']);
+        $member->setPersonId((int)$record['personId']);
+        $member->setImage($record['image']);
+        $member->setAdressCity($record['addressCity']);
+        $member->setStreetAdress($record['streetAddress']);
+        $member->setStreetAdressSecond($record['streetAddressSecond']);
+        $member->setStreetAdressThird($record['streetAddressThird']);
+        $member->setPostalCode($record['postalCode']);
+        $member->setTelphone($record['telphone']);
+        $member->setMobilPhone($record['mobilPhone']);
+        $member->setEmail($record['email']);
 
 
         return $member;
         return $member;
     }
     }
-
-    /**
-     * Returns an array of Member objects from an array of Api records
-     *
-     * @param $records
-     * @return array
-     * @throws \Exception
-     */
-    private function membersFromJson($records) {
-        $members = [];
-        foreach ($records as $record) {
-            $members[] = $this->memberFromJson($record);
-        }
-        return $members;
-    }
-
-    /**
-     * Get the members of the organization
-     * If $only_ca is true, returns only the members onf the CA
-     *
-     * @param int $organizationId The id of the organization
-     * @param bool $only_ca If true, returns the CA members instead of all the members
-     * @return array              Members
-     * @throws ApiRequestException
-     * @throws \Exception
-     */
-    public function findByOrganizationId(int $organizationId, bool $only_ca = false) {
-        $params = [];
-        $params['filter[where][organizationId]'] = $organizationId;
-
-        if ($only_ca) {
-            $records = $this->getApiRecords($this::URI_CA, $params);
-        } else {
-            $records = $this->getApiRecords($this::URI, $params);
-        }
-
-        return $this->membersFromJson($records);
-    }
-
 }
 }

+ 38 - 39
ot_templating/Classes/Domain/Repository/OrganizationRepository.php

@@ -11,38 +11,6 @@ class OrganizationRepository extends BaseApiRepository
     CONST URI = BaseApiRepository::BASE_URI . 'public/organizations';
     CONST URI = BaseApiRepository::BASE_URI . 'public/organizations';
     const HYDRA_TYPE = 'PortailOrganization';
     const HYDRA_TYPE = 'PortailOrganization';
 
 
-    /**
-     * Returns an Organization object from an Api record
-     *
-     * @param $record
-     * @return Organization|null
-     */
-    private function organizationFromJson($record) {
-        if ($record->{'@type'} != $this::HYDRA_TYPE) {
-            return null;
-        }
-        $organization = new Organization();
-        $a = explode('/', $record->{'@id'});
-        $organization->setId(end($a));
-        $organization->setSubdomain($record->{'subDomain'});
-        $organization->setName($record->{'name'});
-        $organization->setSlug($record->{'slug'});
-        $organization->setPrincipalType($record->{'principalType'});
-        $organization->setDescription($record->{'description'});
-        $organization->setCategories($record->{'categories'});
-        $organization->setAddressCity($record->{'addressCity'});
-        $organization->setPostalCode($record->{'postalCode'});
-        $organization->setStreetAdress($record->{'streetAddress'});
-        $organization->setLatitude($record->{'latitude'});
-        $organization->setLongitude($record->{'longitude'});
-        $organization->setCountry($record->{'country'});
-        $organization->setLogo($record->{'logo'});
-        $organization->setParentId($record->{'parentId'});
-        $organization->setParentName($record->{'parentName'});
-        $organization->setParentSubdomain($record->{'parentSubDomain'});
-        return $organization;
-    }
-
     /**
     /**
      * Returns an array of Organization objects from an array of Api records
      * Returns an array of Organization objects from an array of Api records
      *
      *
@@ -67,8 +35,7 @@ class OrganizationRepository extends BaseApiRepository
     public function findById($id) {
     public function findById($id) {
         $params = [];
         $params = [];
         $params['filter[where][id]'] = $id;
         $params['filter[where][id]'] = $id;
-        $record = $this->getApiFirstRecord($this::URI, $params);
-        $organization = $this->organizationFromJson($record);
+        $organization = $this->getApiFirstRecord($this::URI, $params);
         if($organization == null) {
         if($organization == null) {
             throw new ApiRequestException('Organization with id ' . $id . ' does not exist');
             throw new ApiRequestException('Organization with id ' . $id . ' does not exist');
         }
         }
@@ -87,8 +54,7 @@ class OrganizationRepository extends BaseApiRepository
     {
     {
         $params = [];
         $params = [];
         $params['filter[where][name]'] = $name;
         $params['filter[where][name]'] = $name;
-        $data = $this->getApiFirstRecord($this::URI, $params);
-        $organization = $this->organizationFromJson($data);
+        $organization = $this->getApiFirstRecord($this::URI, $params);
         if($organization == null) {
         if($organization == null) {
             throw new \Exception('Organization with name "' . $name . '" does not exist');
             throw new \Exception('Organization with name "' . $name . '" does not exist');
         }
         }
@@ -100,19 +66,52 @@ class OrganizationRepository extends BaseApiRepository
      *
      *
      * @param int $id The id of the organization
      * @param int $id The id of the organization
      * @param array $searchParams An array of parameters which will be passed to the Api request as URI parameters
      * @param array $searchParams An array of parameters which will be passed to the Api request as URI parameters
+     * @param int $page
      * @return array
      * @return array
      * @throws ApiRequestException
      * @throws ApiRequestException
      */
      */
-    public function findChildrenById($id, $searchParams = [])
+    public function findChildrenById(int $id, $searchParams = [], $page = 1)
     {
     {
         $params = [];
         $params = [];
         $params['parentId'] = $id;
         $params['parentId'] = $id;
         $params['children'] = 1;
         $params['children'] = 1;
+        $params['page'] = $page;
 
 
         $params = array_merge($params, $searchParams);
         $params = array_merge($params, $searchParams);
 
 
-        $record = $this->getApiRecords($this::URI, $params);
-        return $this->organizationsFromJson($record);
+        return $this->getApiRecords($this::URI, $params);
+    }
+
+    /**
+     * Returns an Organization object from an Api record
+     *
+     * @param $record
+     * @return Organization|null
+     */
+    protected function memberToObject(array $record) {
+        if ($record['@type'] != $this::HYDRA_TYPE) {
+            return null;
+        }
+        $organization = new Organization();
+        $a = explode('/', $record['@id']);
+        $organization->setId(end($a));
+        $organization->setSubdomain($record['subDomain']);
+        $organization->setName($record['name']);
+        $organization->setSlug($record['slug']);
+        $organization->setPrincipalType($record['principalType']);
+        $organization->setDescription($record['description']);
+        $organization->setCategories($record['categories']);
+        $organization->setAddressCity($record['addressCity']);
+        $organization->setPostalCode($record['postalCode']);
+        $organization->setStreetAdress($record['streetAddress']);
+        $organization->setLatitude($record['latitude']);
+        $organization->setLongitude($record['longitude']);
+        $organization->setCountry($record['country']);
+        $organization->setLogo($record['logo']);
+        $organization->setParentId($record['parentId']);
+        $organization->setParentName($record['parentName']);
+        $organization->setParentSubdomain($record['parentSubDomain']);
+        return $organization;
     }
     }
 
 
 }
 }

+ 1 - 1
ot_templating/Classes/ViewHelpers/Donors/GetAllViewHelper.php

@@ -11,7 +11,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 
 
 /**
 /**
- *   This view helper give access to an array named according to the 'as' variable
+ *   This view helper give access to an ApiPagedCollection named according to the 'as' variable
  *   and which contains all the donors of the given structure
  *   and which contains all the donors of the given structure
  *
  *
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}

+ 1 - 1
ot_templating/Classes/ViewHelpers/Events/GetAllViewHelper.php

@@ -10,7 +10,7 @@ use Psr\Log\LoggerAwareTrait;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 
 
 /**
 /**
- *   This view helper give access to an array named according to the 'as' variable
+ *   This view helper give access to an ApiPagedCollection named according to the 'as' variable
  *   and containing all the upcoming events of the structure
  *   and containing all the upcoming events of the structure
  *
  *
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}

+ 1 - 1
ot_templating/Classes/ViewHelpers/Events/GetNextViewHelper.php

@@ -13,7 +13,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 
 
 /**
 /**
- *   This view helper provides an array named according to the 'as' variable
+ *   This view helper provides an ApiPagedCollection named according to the 'as' variable
  *   and which contains the next events of the structure
  *   and which contains the next events of the structure
  *
  *
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}

+ 2 - 1
ot_templating/Classes/ViewHelpers/Members/GetAllCaViewHelper.php

@@ -104,7 +104,8 @@ class GetAllCaViewHelper extends AbstractViewHelper implements LoggerAwareInterf
 
 
         // Get members of the structure (only CA members)
         // Get members of the structure (only CA members)
         try {
         try {
-            $members = $this->memberRepository->findByOrganizationId($organizationId, true);
+            $collection = $this->memberRepository->findByOrganizationId($organizationId, true);
+            $members = $collection->getMembers();
         } catch (ApiRequestException $e) {
         } catch (ApiRequestException $e) {
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $members = [];
             $members = [];

+ 2 - 1
ot_templating/Classes/ViewHelpers/Members/GetAllViewHelper.php

@@ -83,7 +83,8 @@ class GetAllViewHelper extends AbstractViewHelper implements LoggerAwareInterfac
 
 
         try {
         try {
             // Get members of the structure
             // Get members of the structure
-            $members = $this->memberRepository->findByOrganizationId($organizationId);
+            $collection = $this->memberRepository->findByOrganizationId($organizationId);
+            $members = $collection->getMembers();
         } catch (ApiRequestException $e) {
         } catch (ApiRequestException $e) {
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $members = [];
             $members = [];

+ 17 - 4
ot_templating/Classes/ViewHelpers/Organizations/GetChildrenViewHelper.php

@@ -10,7 +10,7 @@ use Psr\Log\LoggerAwareTrait;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 
 
 /**
 /**
- *   This view helper returns the organization children structures
+ *   This view helper returns the organization children structures as an ApiPagedCollection
  *
  *
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  *
  *
@@ -56,6 +56,13 @@ class GetChildrenViewHelper extends AbstractViewHelper implements LoggerAwareInt
             'Id of the organization',
             'Id of the organization',
             true
             true
         );
         );
+        $this->registerArgument(
+            'page',
+            'integer',
+            'Page number',
+            false,
+            1
+        );
     }
     }
 
 
     /**
     /**
@@ -63,12 +70,12 @@ class GetChildrenViewHelper extends AbstractViewHelper implements LoggerAwareInt
      * Renders the content as html
      * Renders the content as html
      *
      *
      * @return string
      * @return string
-     * @throws ApiRequestException
      */
      */
     public function render()
     public function render()
     {
     {
         $as = $this->arguments['as'];
         $as = $this->arguments['as'];
         $organizationId = $this->arguments['organizationId'];
         $organizationId = $this->arguments['organizationId'];
+        $page = $this->arguments['page'];
 
 
         $searchParams = [];
         $searchParams = [];
 
 
@@ -77,13 +84,19 @@ class GetChildrenViewHelper extends AbstractViewHelper implements LoggerAwareInt
         }
         }
 
 
         try {
         try {
-            $organizations = $this->organizationRepository->findChildrenById($organizationId, $searchParams);
+            $organizations = $this->organizationRepository->findChildrenById(
+                $organizationId,
+                $searchParams,
+                $page
+            );
         } catch (ApiRequestException $e) {
         } catch (ApiRequestException $e) {
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $organizations = [];
             $organizations = [];
         }
         }
 
 
-        $variables = [$as => $organizations];
+        $variables = [
+            $as => $organizations
+        ];
         return $this->renderChildrenWithVariables($variables);
         return $this->renderChildrenWithVariables($variables);
     }
     }
 
 

+ 1 - 1
ot_templating/Resources/Private/Layouts/Classic/Events.html

@@ -23,7 +23,7 @@
             </f:then>
             </f:then>
             <f:else>
             <f:else>
                 <f:comment><!-- No specific event was requested: show all events --></f:comment>
                 <f:comment><!-- No specific event was requested: show all events --></f:comment>
-                <ot:events.getAll as="events"
+                <ot:events.getAll as="eventsCollection"
                                    organizationId="{settings.organizationId}">
                                    organizationId="{settings.organizationId}">
                     <f:render partial="Classic/EventsIndex" arguments="{_all}"/>
                     <f:render partial="Classic/EventsIndex" arguments="{_all}"/>
                 </ot:events.getAll>
                 </ot:events.getAll>

+ 6 - 4
ot_templating/Resources/Private/Layouts/Classic/Structures.html

@@ -15,10 +15,12 @@
 
 
         <div class="ot-structures">
         <div class="ot-structures">
 
 
-            <ot:organizations.getChildren as="structures"
+            <ot:organizations.getChildren as="structuresCollection"
                                           organizationId="{settings.organizationId}">
                                           organizationId="{settings.organizationId}">
 
 
 
 
+                <f:debug>{_all}</f:debug>
+
                 <div class="ot-structures">
                 <div class="ot-structures">
                     <div class="structure-controls">
                     <div class="structure-controls">
                         <div class="structure-search">
                         <div class="structure-search">
@@ -33,7 +35,7 @@
                         </div>
                         </div>
 
 
                         <div id="structure-map">
                         <div id="structure-map">
-                            <f:for each="{structures}" as="structure" iteration="it">
+                            <f:for each="{structuresCollection.members}" as="structure" iteration="it">
                                 <f:if condition="{structure.longitude}">
                                 <f:if condition="{structure.longitude}">
                                     <i class="item-geodata" style="display: none;"
                                     <i class="item-geodata" style="display: none;"
                                        data-id="{structure.id}"
                                        data-id="{structure.id}"
@@ -47,11 +49,11 @@
                     </div>
                     </div>
 
 
                     <div class="structure-results">
                     <div class="structure-results">
-                        <f:if condition="{structures -> f:count()} == 0">
+                        <f:if condition="{structuresCollection.totalItems} == 0">
                             <span>Aucun résultat</span>
                             <span>Aucun résultat</span>
                         </f:if>
                         </f:if>
 
 
-                        <f:for each="{structures}" as="structure">
+                        <f:for each="{structuresCollection.members}" as="structure">
                             <div class="structure" data-id="{structure.id}">
                             <div class="structure" data-id="{structure.id}">
                                 <div class="structure-preview">
                                 <div class="structure-preview">
 
 

+ 4 - 4
ot_templating/Resources/Private/Layouts/Classic/StructuresEvents.html

@@ -14,7 +14,7 @@
 
 
 
 
         <f:comment><!-- All structures' events --></f:comment>
         <f:comment><!-- All structures' events --></f:comment>
-        <ot:events.getAll as="events"
+        <ot:events.getAll as="eventsCollection"
                           organizationId="{settings.organizationId}"
                           organizationId="{settings.organizationId}"
                           fromChildren="1">
                           fromChildren="1">
 
 
@@ -47,7 +47,7 @@
                     </div>
                     </div>
 
 
                     <div id="event-map" data-records="">
                     <div id="event-map" data-records="">
-                        <f:for each="{events}" as="event">
+                        <f:for each="{eventsCollection.members}" as="event">
                             <f:if condition="{event.longitude}">
                             <f:if condition="{event.longitude}">
                                 <f:then>
                                 <f:then>
                                     <i class="item-geodata" style="display: none;"
                                     <i class="item-geodata" style="display: none;"
@@ -63,11 +63,11 @@
                 </div>
                 </div>
 
 
                 <div class="events-results">
                 <div class="events-results">
-                    <f:if condition="{events -> f:count()} == 0">
+                    <f:if condition="{eventsCollection.totalItems} == 0">
                         <span>Aucun résultat</span>
                         <span>Aucun résultat</span>
                     </f:if>
                     </f:if>
 
 
-                    <f:for each="{events}" as="event">
+                    <f:for each="{eventsCollection.members}" as="event">
                         <div class="event" data-id="{event.id}">
                         <div class="event" data-id="{event.id}">
                             <div class="event-preview">
                             <div class="event-preview">
 
 

+ 1 - 1
ot_templating/Resources/Private/Layouts/Modern/Events.html

@@ -25,7 +25,7 @@
                             </f:then>
                             </f:then>
                             <f:else>
                             <f:else>
                                 <f:comment><!-- No specific event was requested: show all events --></f:comment>
                                 <f:comment><!-- No specific event was requested: show all events --></f:comment>
-                                <ot:events.getAll as="events"
+                                <ot:events.getAll as="eventsCollection"
                                                   organizationId="{settings.organizationId}">
                                                   organizationId="{settings.organizationId}">
                                     <f:render partial="Modern/EventsIndex" arguments="{_all}"/>
                                     <f:render partial="Modern/EventsIndex" arguments="{_all}"/>
                                 </ot:events.getAll>
                                 </ot:events.getAll>

+ 2 - 2
ot_templating/Resources/Private/Layouts/Modern/Members.html

@@ -23,10 +23,10 @@
                                     <f:for each="{members}" as="member" iteration="i">
                                     <f:for each="{members}" as="member" iteration="i">
 
 
                                         <f:if condition="{i.index -> v:math.modulo(b: 4)}===0">
                                         <f:if condition="{i.index -> v:math.modulo(b: 4)}===0">
-                                            <if condition="i>1">
+                                            <f:if condition="i>1">
                                         </div>
                                         </div>
                                             </div>
                                             </div>
-                                            </if>
+                                            </f:if>
 
 
                                         <div class="team-3 mb-50 mt-70">
                                         <div class="team-3 mb-50 mt-70">
                                             <div class="row">
                                             <div class="row">

+ 3 - 3
ot_templating/Resources/Private/Layouts/Modern/MembersCa.html

@@ -16,7 +16,7 @@
                     <div class="col-lg-12 col-md-12">
                     <div class="col-lg-12 col-md-12">
                         <h1 class="text-center">Liste des membres du CA</h1>
                         <h1 class="text-center">Liste des membres du CA</h1>
 
 
-                        <ot:members.getAllCa as="members"
+                        <ot:members.getAllCa as="membersCollection"
                                            organizationId="{settings.organizationId}">
                                            organizationId="{settings.organizationId}">
 
 
                             <f:if condition="{members -> f:count()} > 0">
                             <f:if condition="{members -> f:count()} > 0">
@@ -24,10 +24,10 @@
                                     <f:for each="{members}" as="member" iteration="i">
                                     <f:for each="{members}" as="member" iteration="i">
 
 
                                         <f:if condition="{i.index -> v:math.modulo(b: 4)}===0">
                                         <f:if condition="{i.index -> v:math.modulo(b: 4)}===0">
-                                            <if condition="i>1">
+                                            <f:if condition="i>1">
                                         </div>
                                         </div>
                                             </div>
                                             </div>
-                                            </if>
+                                            </f:if>
 
 
                                         <div class="team-3 mb-50 mt-70">
                                         <div class="team-3 mb-50 mt-70">
                                             <div class="row">
                                             <div class="row">

+ 4 - 4
ot_templating/Resources/Private/Layouts/Modern/Structures.html

@@ -20,7 +20,7 @@
 
 
                         <div class="ot-structures">
                         <div class="ot-structures">
 
 
-                            <ot:organizations.getChildren as="structures"
+                            <ot:organizations.getChildren as="structuresCollection"
                                                           organizationId="{settings.organizationId}">
                                                           organizationId="{settings.organizationId}">
 
 
 
 
@@ -38,7 +38,7 @@
                                         </div>
                                         </div>
 
 
                                         <div id="structure-map">
                                         <div id="structure-map">
-                                            <f:for each="{structures}" as="structure" iteration="it">
+                                            <f:for each="{structuresCollection.members}" as="structure" iteration="it">
                                                 <f:if condition="{structure.longitude}">
                                                 <f:if condition="{structure.longitude}">
                                                     <i class="item-geodata" style="display: none;"
                                                     <i class="item-geodata" style="display: none;"
                                                        data-id="{structure.id}"
                                                        data-id="{structure.id}"
@@ -52,11 +52,11 @@
                                     </div>
                                     </div>
 
 
                                     <div class="structure-results">
                                     <div class="structure-results">
-                                        <f:if condition="{structures -> f:count()} == 0">
+                                        <f:if condition="{structuresCollection.totalItems} == 0">
                                             <span>Aucun résultat</span>
                                             <span>Aucun résultat</span>
                                         </f:if>
                                         </f:if>
 
 
-                                        <f:for each="{structures}" as="structure">
+                                        <f:for each="{structuresCollection.members}" as="structure">
                                             <div class="structure" data-id="{structure.id}">
                                             <div class="structure" data-id="{structure.id}">
                                                 <div class="structure-preview">
                                                 <div class="structure-preview">
 
 

+ 11 - 11
ot_templating/Resources/Private/Layouts/Modern/StructuresEvents.html

@@ -16,7 +16,7 @@
                     <div class="col-sm-12 mt-30">
                     <div class="col-sm-12 mt-30">
 
 
                         <f:comment><!-- All structures' events --></f:comment>
                         <f:comment><!-- All structures' events --></f:comment>
-                        <ot:events.getAll as="events"
+                        <ot:events.getAll as="eventsCollection"
                                           organizationId="{settings.organizationId}"
                                           organizationId="{settings.organizationId}"
                                           fromChildren="1">
                                           fromChildren="1">
 
 
@@ -49,7 +49,7 @@
                                     </div>
                                     </div>
 
 
                                     <div id="event-map" data-records="">
                                     <div id="event-map" data-records="">
-                                        <f:for each="{events}" as="event">
+                                        <f:for each="{eventsCollection.members}" as="event">
                                             <f:if condition="{event.longitude}">
                                             <f:if condition="{event.longitude}">
                                                 <f:then>
                                                 <f:then>
                                                     <i class="item-geodata" style="display: none;"
                                                     <i class="item-geodata" style="display: none;"
@@ -65,11 +65,11 @@
                                 </div>
                                 </div>
 
 
                                 <div class="events-results">
                                 <div class="events-results">
-                                    <f:if condition="{events -> f:count()} == 0">
+                                    <f:if condition="{eventsCollection.totalItems} == 0">
                                         <span>Aucun résultat</span>
                                         <span>Aucun résultat</span>
                                     </f:if>
                                     </f:if>
 
 
-                                    <f:for each="{events}" as="event">
+                                    <f:for each="{eventsCollection.members}" as="event">
                                         <div class="event" data-id="{event.id}">
                                         <div class="event" data-id="{event.id}">
                                             <div class="event-preview">
                                             <div class="event-preview">
 
 
@@ -85,15 +85,15 @@
                                                 </div>
                                                 </div>
 
 
                                                 <div class="event-summary">
                                                 <div class="event-summary">
-                                    <span class="event-name">
-                                        {event.name}
-                                    </span>
+                                                    <span class="event-name">
+                                                        {event.name}
+                                                    </span>
                                                     <span class="event-loc-date">
                                                     <span class="event-loc-date">
-                                        {event.locAndDate}
-                                    </span>
+                                                        {event.locAndDate}
+                                                    </span>
                                                     <span class="event-description">
                                                     <span class="event-description">
-                                        {event.shortDescription}
-                                    </span>
+                                                        {event.shortDescription}
+                                                    </span>
                                                 </div>
                                                 </div>
                                             </div>
                                             </div>
 
 

+ 3 - 3
ot_templating/Resources/Private/Partials/Classic/Donors.html

@@ -4,11 +4,11 @@
 <f:comment><!-- Donors --></f:comment>
 <f:comment><!-- Donors --></f:comment>
 
 
 <div class="ot-box ot-donors">
 <div class="ot-box ot-donors">
-    <ot:donors.getAll as="donors"
+    <ot:donors.getAll as="donorsCollection"
                       organizationId="{settings.organizationId}"
                       organizationId="{settings.organizationId}"
                       fromParents="{fromParents}">
                       fromParents="{fromParents}">
 
 
-        <f:if condition="{donors -> f:count()} > 0">
+        <f:if condition="{donorsCollection.totalItems} > 0">
             <div class="donors-panel">
             <div class="donors-panel">
                 <header>
                 <header>
                     <f:if condition="{fromParents}==1">
                     <f:if condition="{fromParents}==1">
@@ -23,7 +23,7 @@
                 </header>
                 </header>
                 <div class="box-content">
                 <div class="box-content">
                     <div class="donor-list {f:if(condition: '{settings.staticDonors}==0', then: 'carousel')}">
                     <div class="donor-list {f:if(condition: '{settings.staticDonors}==0', then: 'carousel')}">
-                        <f:for each="{donors}" as="donor">
+                        <f:for each="{donorsCollection.members}" as="donor">
                             <div class="donor-card">
                             <div class="donor-card">
                                 <img src="{donor.logo}" alt="{donor.name}"/>
                                 <img src="{donor.logo}" alt="{donor.name}"/>
                             </div>
                             </div>

+ 3 - 3
ot_templating/Resources/Private/Partials/Classic/EventsIndex.html

@@ -31,7 +31,7 @@
         </div>
         </div>
 
 
         <div id="event-map" data-records="">
         <div id="event-map" data-records="">
-            <f:for each="{events}" as="event">
+            <f:for each="{eventsCollection.members}" as="event">
                 <f:if condition="{event.longitude}">
                 <f:if condition="{event.longitude}">
                     <f:then>
                     <f:then>
                         <i class="item-geodata" style="display: none;"
                         <i class="item-geodata" style="display: none;"
@@ -47,11 +47,11 @@
     </div>
     </div>
 
 
     <div class="events-results">
     <div class="events-results">
-        <f:if condition="{events -> f:count()} == 0">
+        <f:if condition="{eventsCollection.totalItems} == 0">
             <span>Aucun résultat</span>
             <span>Aucun résultat</span>
         </f:if>
         </f:if>
 
 
-        <f:for each="{events}" as="event">
+        <f:for each="{eventsCollection.members}" as="event">
             <div class="event" data-id="{event.id}">
             <div class="event" data-id="{event.id}">
                 <div class="event-preview">
                 <div class="event-preview">
 
 

+ 3 - 3
ot_templating/Resources/Private/Partials/Classic/NextEvents.html

@@ -26,14 +26,14 @@
             </f:if>
             </f:if>
         </header>
         </header>
 
 
-        <ot:events.getNext as="events"
+        <ot:events.getNext as="eventsCollection"
                            organizationId="{settings.organizationId}"
                            organizationId="{settings.organizationId}"
                            limit="{settings.eventsLimit}"
                            limit="{settings.eventsLimit}"
                            period="{settings.eventsPeriod}"
                            period="{settings.eventsPeriod}"
                            fromParents="{fromParents}"
                            fromParents="{fromParents}"
                            fromChildren="{fromChildren}">
                            fromChildren="{fromChildren}">
 
 
-            <f:for each="{events}" as="event">
+            <f:for each="{eventsCollection.members}" as="event">
 
 
                 <div class="event-card">
                 <div class="event-card">
 
 
@@ -82,7 +82,7 @@
                 </div>
                 </div>
             </f:for>
             </f:for>
 
 
-            <f:if condition="{events -> f:count()} == 0">
+            <f:if condition="{eventsCollection.totalItems} == 0">
                 <f:then>
                 <f:then>
                     <span class="no-events">
                     <span class="no-events">
                         Aucun évènement dans les prochaines semaines
                         Aucun évènement dans les prochaines semaines

+ 3 - 3
ot_templating/Resources/Private/Partials/Modern/Donors.html

@@ -7,11 +7,11 @@
     <div class="container">
     <div class="container">
         <div class="row mb-30 mt-100 sm-mt-50">
         <div class="row mb-30 mt-100 sm-mt-50">
 
 
-            <ot:donors.getAll as="donors"
+            <ot:donors.getAll as="donorsCollection"
                               organizationId="{settings.organizationId}"
                               organizationId="{settings.organizationId}"
                               fromParents="{fromParents}">
                               fromParents="{fromParents}">
 
 
-                <f:if condition="{donors -> f:count()} > 0">
+                <f:if condition="{donorsCollection.totalItems} > 0">
                     <div class="col-lg-12 col-md-12">
                     <div class="col-lg-12 col-md-12">
                         <div class="text-center">
                         <div class="text-center">
                             <h2 class="mb-50">
                             <h2 class="mb-50">
@@ -29,7 +29,7 @@
                                  data-sm-items="3"
                                  data-sm-items="3"
                                  data-xs-items="2"
                                  data-xs-items="2"
                                  data-xx-items="2">
                                  data-xx-items="2">
-                                <f:for each="{donors}" as="donor">
+                                <f:for each="{donorsCollection.members}" as="donor">
 
 
                                     <div class="item">
                                     <div class="item">
                                         <img class="img-fluid mx-auto"
                                         <img class="img-fluid mx-auto"

+ 3 - 3
ot_templating/Resources/Private/Partials/Modern/EventsIndex.html

@@ -31,7 +31,7 @@
         </div>
         </div>
 
 
         <div id="event-map" data-records="">
         <div id="event-map" data-records="">
-            <f:for each="{events}" as="event">
+            <f:for each="{eventsCollection.members}" as="event">
                 <f:if condition="{event.longitude}">
                 <f:if condition="{event.longitude}">
                     <f:then>
                     <f:then>
                         <i class="item-geodata" style="display: none;"
                         <i class="item-geodata" style="display: none;"
@@ -47,11 +47,11 @@
     </div>
     </div>
 
 
     <div class="events-results">
     <div class="events-results">
-        <f:if condition="{events -> f:count()} == 0">
+        <f:if condition="{eventsCollection.totalItems} == 0">
             <span>Aucun résultat</span>
             <span>Aucun résultat</span>
         </f:if>
         </f:if>
 
 
-        <f:for each="{events}" as="event">
+        <f:for each="{eventsCollection.members}" as="event">
             <div class="event" data-id="{event.id}">
             <div class="event" data-id="{event.id}">
                 <div class="event-preview">
                 <div class="event-preview">
 
 

+ 3 - 3
ot_templating/Resources/Private/Partials/Modern/NextEvents.html

@@ -21,14 +21,14 @@
     <div class="container">
     <div class="container">
         <div class="row">
         <div class="row">
 
 
-            <ot:events.getNext as="events"
+            <ot:events.getNext as="eventsCollection"
                                organizationId="{settings.organizationId}"
                                organizationId="{settings.organizationId}"
                                limit="{settings.eventsLimit}"
                                limit="{settings.eventsLimit}"
                                period="{settings.eventsPeriod}"
                                period="{settings.eventsPeriod}"
                                fromParents="{fromParents}"
                                fromParents="{fromParents}"
                                fromChildren="{fromChildren}">
                                fromChildren="{fromChildren}">
 
 
-                <f:if condition="{events -> f:count()} > 0 || {showEmpty}">
+                <f:if condition="{eventsCollection.totalItems} > 0 || {showEmpty}">
 
 
                     <div class="col-lg-12 col-md-12">
                     <div class="col-lg-12 col-md-12">
                         <div class="text-center">
                         <div class="text-center">
@@ -46,7 +46,7 @@
                         </div>
                         </div>
                     </div>
                     </div>
 
 
-                    <f:for each="{events}" as="event">
+                    <f:for each="{eventsCollection.totalItems}" as="event">
 
 
                         <div class="card-container col-lg-3 col-md-6 col-sm-12 sm-mb-30">
                         <div class="card-container col-lg-3 col-md-6 col-sm-12 sm-mb-30">
                             <div class="card border-0 theme-bg o-hidden h-100">
                             <div class="card border-0 theme-bg o-hidden h-100">

+ 0 - 1
ot_templating/Resources/Private/Templates/Page/3Col.html

@@ -17,7 +17,6 @@
             <flux:grid.column colPos="2" name="Rightcol" label="Colonne Droite" style="width: 25%" />
             <flux:grid.column colPos="2" name="Rightcol" label="Colonne Droite" style="width: 25%" />
         </flux:grid.row>
         </flux:grid.row>
     </flux:grid>
     </flux:grid>
-
 </f:section>
 </f:section>
 
 
 <f:section name="Leftcol">
 <f:section name="Leftcol">

+ 1 - 0
ot_templating/Resources/Private/Templates/Page/Contact.html

@@ -1,3 +1,4 @@
+{namespace flux=FluidTYPO3\Flux\ViewHelpers}
 {namespace ot=Opentalent\OtTemplating\ViewHelpers}
 {namespace ot=Opentalent\OtTemplating\ViewHelpers}
 
 
 <f:comment><!-- uses the layout Contact, defined in layouts/[templateName]/Contact.html --></f:comment>
 <f:comment><!-- uses the layout Contact, defined in layouts/[templateName]/Contact.html --></f:comment>