Bläddra i källkod

Merge branch 'release/0.6.4'

Olivier Massot 3 år sedan
förälder
incheckning
01ec334ec0
36 ändrade filer med 126 tillägg och 96 borttagningar
  1. 0 1
      doc/env.md
  2. 19 6
      ot_admin/Classes/Controller/SiteController.php
  3. 2 2
      ot_admin/Classes/Http/ApiController.php
  4. 1 1
      ot_admin/ext_emconf.php
  5. 1 1
      ot_connect/ext_emconf.php
  6. 3 13
      ot_core/Classes/Domain/Repository/BaseApiRepository.php
  7. 2 2
      ot_core/Classes/Domain/Repository/MemberRepository.php
  8. 1 1
      ot_core/Classes/Logging/OtLogger.php
  9. 10 15
      ot_core/Classes/Service/OpentalentApiService.php
  10. 1 1
      ot_core/Classes/Service/OpentalentEnvService.php
  11. 2 2
      ot_core/Classes/ViewHelpers/OtAbstractViewHelper.php
  12. 2 2
      ot_core/Classes/Website/OtWebsiteRepository.php
  13. 0 6
      ot_core/Configuration/ot_config.yaml
  14. 1 1
      ot_core/Tests/Unit/Domain/Repository/MemberRepositoryTest.php
  15. 2 2
      ot_core/Tests/Unit/Fixtures/ApiResponseFixtures.php
  16. 1 1
      ot_core/ext_emconf.php
  17. 2 2
      ot_core/ext_localconf.php
  18. 1 1
      ot_optimizer/ext_emconf.php
  19. 1 1
      ot_stats/ext_emconf.php
  20. 3 2
      ot_templating/Classes/ViewHelpers/Donors/GetAllViewHelper.php
  21. 2 2
      ot_templating/Classes/ViewHelpers/Events/GetAllViewHelper.php
  22. 2 1
      ot_templating/Classes/ViewHelpers/Events/GetByIdViewHelper.php
  23. 2 1
      ot_templating/Classes/ViewHelpers/Events/GetNextViewHelper.php
  24. 14 14
      ot_templating/Classes/ViewHelpers/Members/GetAllCaViewHelper.php
  25. 2 1
      ot_templating/Classes/ViewHelpers/Members/GetAllViewHelper.php
  26. 3 2
      ot_templating/Classes/ViewHelpers/Members/GetPresidentViewHelper.php
  27. 2 1
      ot_templating/Classes/ViewHelpers/Organizations/GetByIdViewHelper.php
  28. 2 1
      ot_templating/Classes/ViewHelpers/Organizations/GetChildrenViewHelper.php
  29. 1 0
      ot_templating/Configuration/TypoScript/constants.txt
  30. 9 0
      ot_templating/Configuration/TypoScript/setup.txt
  31. 7 0
      ot_templating/Resources/Private/Forms/Contact.form.yaml
  32. 8 0
      ot_templating/Resources/Private/Partials/Classic/Footer.html
  33. 4 4
      ot_templating/Resources/Private/Partials/Modern/Carousel.html
  34. 8 0
      ot_templating/Resources/Private/Partials/Modern/Footer.html
  35. 4 5
      ot_templating/Resources/Private/Templates/Content/Carousel.html
  36. 1 1
      ot_templating/ext_emconf.php

+ 0 - 1
doc/env.md

@@ -13,4 +13,3 @@ ces variables dans le fichier typo3/public/typo3conf/AdditionalConfiguration.php
 Exemple:
 
     $GLOBALS['OT']['API_BASE_URI'] = 'http://docker.nginx.opentalent.fr';
-

+ 19 - 6
ot_admin/Classes/Controller/SiteController.php

@@ -100,8 +100,8 @@ class SiteController extends ActionController
 
     // Redirections creation status
     private const REDIRECTION_UNKNOWN_STATUS = 0;
-    private const REDIRECTION_UPDATED = 1;
-    private const REDIRECTION_CREATED = 2;
+    public const REDIRECTION_UPDATED = 1;
+    public const REDIRECTION_CREATED = 2;
 
     /**
      * @var ConnectionPool
@@ -502,6 +502,7 @@ class SiteController extends ActionController
             $include .= ",EXT:frontend_editing/Configuration/TypoScript";
             $include .= ",EXT:frontend_editing/Configuration/TypoScript/FluidStyledContent9";
             $include .= ",EXT:ot_templating/Configuration/TypoScript";
+            $include .= ",EXT:hcaptcha/Configuration/TypoScript";
 
             $queryBuilder = $this->connectionPool->getQueryBuilderForTable('sys_template');
             $queryBuilder->insert('sys_template')
@@ -1769,7 +1770,9 @@ class SiteController extends ActionController
         $backupConfigDir = $_ENV['TYPO3_PATH_APP'] . "/config/bkp_sites";
 
         if (file_exists($backupConfigDir)) {
-            throw new RuntimeException('A directory or a file with this name already exist: ' . $backupConfigDir);
+            throw new RuntimeException(
+                'A directory or a file with this name already exist: ' . $backupConfigDir . '. Delete it before continuing.'
+            );
         }
 
         $this->connectionPool->getConnectionByName('Default')->beginTransaction();
@@ -1781,16 +1784,25 @@ class SiteController extends ActionController
             $websites = $this->otWebsiteRepository->getAll();
 
             foreach ($websites as $website) {
-                $identifier = $website['subdomain'] . '_' . $website['organization_id'];
+                if (!((int)$website['organization_id'] > 0)) {
+                    continue;
+                }
+
+                $identifier = str_replace('/', '', $website['subdomain']) . '_' . $website['organization_id'];
                 $configDir = $configRootDir . $identifier;
                 $configFilename = $configDir . "/config.yaml";
 
                 $siteConfig = $this->otWebsiteRepository->generateWebsiteConfiguration($website, $identifier);
+
                 $config = $siteConfig->getConfiguration();
 
                 $yamlConfig = Yaml::dump($config, 99, 2);
 
-                $this->mkDir($configDir);
+                try {
+                    $this->mkDir($configDir);
+                } catch (\Throwable $e) {
+                    throw new RuntimeException('Unable to create the directory ' . $configDir, 0, $e);
+                }
                 $this->writeFile($configFilename, $yamlConfig);
 
                 // ## Update the ot_website identifier
@@ -2024,7 +2036,7 @@ class SiteController extends ActionController
         $cnn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
         $stmt = $cnn->query(
-            "SELECT o.id, o.name, o.facebook, o.twitter, o.instagram, 
+            "SELECT o.id, o.name, o.facebook, o.twitter, o.instagram, o.youtube,
                                  o.category, o.logo_id, p.logoDonorsMove
                           FROM opentalent.Organization o INNER JOIN opentalent.Parameters p 
                           ON o.parameters_id = p.id
@@ -2092,6 +2104,7 @@ class SiteController extends ActionController
             "            twitter = " . $organizationExtraData['twitter'] . "\n" .
             "            facebook = " . $organizationExtraData['facebook'] . "\n" .
             "            instagram = " . $organizationExtraData['instagram'] . "\n" .
+            "            youtube = " . $organizationExtraData['youtube'] . "\n" .
             "        }\n" .
             "    network {\n" .
             "            logo = " . $organizationExtraData['network']['logo'] . "\n" .

+ 2 - 2
ot_admin/Classes/Http/ApiController.php

@@ -191,9 +191,9 @@ class ApiController implements LoggerAwareInterface
         $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
         $res = $controller->addRedirection($fromDomain, $toDomain);
 
-        if ($res == SiteController::REDIRECTION_UPDATED) {
+        if ($res === SiteController::REDIRECTION_UPDATED) {
             $msg = "An existing redirection has been updated ";
-        } elseif ($res == SiteController::REDIRECTION_CREATED) {
+        } elseif ($res === SiteController::REDIRECTION_CREATED) {
             $msg = "A redirection has been added ";
         }
 

+ 1 - 1
ot_admin/ext_emconf.php

@@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '1.0.0',
+    'version' => '1.0.0', //see ot_core/ext_emconf.php to get the current ot extensions version
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 1 - 1
ot_connect/ext_emconf.php

@@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '1.0.0',
+    'version' => '1.0.0', //see ot_core/ext_emconf.php to get the current ot extensions version
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 3 - 13
ot_core/Classes/Domain/Repository/BaseApiRepository.php

@@ -3,26 +3,16 @@
 namespace Opentalent\OtCore\Domain\Repository;
 
 use GuzzleHttp\Client;
-use GuzzleHttp\Exception\GuzzleException;
 use Opentalent\OtCore\Exception\ApiRequestException;
 use Opentalent\OtCore\Service\OpentalentApiService;
-use Psr\Http\Message\ResponseInterface;
-use Psr\Log\LoggerAwareInterface;
-use Psr\Log\LoggerAwareTrait;
-use Symfony\Component\Yaml\Exception\ParseException;
-use Symfony\Component\Yaml\Yaml;
-use TYPO3\CMS\Core\Core\ApplicationContext;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
 
 /**
  *  Base class for repositories based on the Opentalent API
  *
  */
-abstract class BaseApiRepository implements LoggerAwareInterface
+abstract class BaseApiRepository
 {
-    use LoggerAwareTrait;
-
     const URI_TRAILING_PART = '';
     const HYDRA_TYPE = '';
     const DEFAULT_ITEMS_PER_PAGE = 8;
@@ -38,9 +28,9 @@ abstract class BaseApiRepository implements LoggerAwareInterface
 
     /**
      * [FOR TESTS ONLY]
-     * @param Client $client
+     * @param OpentalentApiService $apiService
      */
-    protected function injectService(OpentalentApiService $apiService) {
+    protected function injectOpentalentApiService(OpentalentApiService $apiService) {
         $this->apiService = $apiService;
     }
 

+ 2 - 2
ot_core/Classes/Domain/Repository/MemberRepository.php

@@ -17,14 +17,14 @@ class MemberRepository extends BaseApiRepository
      * 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) {
         $params = [];
         $params['filter[where][organizationId]'] = $organizationId;
-        $params['itemsPerPage'] = '200';
+        $params['itemsPerPage'] = '20000';  // TODO: désactiver la pagination et mieux filtrer quand ce repo sera branché sur la NV,
+                                            // certaines écoles ont des centaines de membres, et pour l'instant les rôles ne sont filtrés qu'après la requête...
         return $this->getApiRecords($params);
     }
 

+ 1 - 1
ot_core/Classes/Logging/OtLogger.php

@@ -11,7 +11,7 @@ class OtLogger implements LoggerAwareInterface
 {
     use LoggerAwareTrait;
 
-    public static function log(int $level, string $msg, array $context = []) {
+    public static function log(string $level, string $msg, array $context = []) {
         $loggerService = GeneralUtility::makeInstance(self::class);
         $loggerService->getLogger()->log($level, $msg, $context);
     }

+ 10 - 15
ot_core/Classes/Service/OpentalentApiService.php

@@ -3,25 +3,20 @@
 namespace Opentalent\OtCore\Service;
 
 use GuzzleHttp\Client;
-use GuzzleHttp\Cookie\CookieJar;
 use GuzzleHttp\Exception\GuzzleException;
 use Opentalent\OtCore\Exception\ApiRequestException;
+use Opentalent\OtCore\Logging\OtLogger;
 use Psr\Http\Message\ResponseInterface;
-use Psr\Log\LoggerAwareInterface;
-use Psr\Log\LoggerAwareTrait;
-use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
 
-class OpentalentApiService implements LoggerAwareInterface
+class OpentalentApiService
 {
-    use LoggerAwareTrait;
-
     protected object $client;
     protected object $context;
 
     /**
-     * @param ObjectManagerInterface $objectManager
-     * @param object|null $client  [For tests only]
-     * @param object|null $context  [For tests only]
+     * @param object|null $client [For tests only]
+     * @param object|null $context [For tests only]
+     * @param object|null $cookieJar
      */
     public function __construct(
         ?object $client = null,
@@ -85,12 +80,12 @@ class OpentalentApiService implements LoggerAwareInterface
     ): array
     {
         $body = $this->getBody($uri, $params);
-        $data = json_decode($body,true);
+        $data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
         if ($data !== null) {
-            return json_decode($body,true);
-        } else {
-            throw new \JsonException('Response can not be decoded as json: ' . substr($body, 0, 300) . '...');
+            return json_decode($body, true, 512, JSON_THROW_ON_ERROR);
         }
+
+        throw new \JsonException('Response can not be decoded as json: ' . substr($body, 0, 300) . '...');
     }
 
     /**
@@ -161,7 +156,7 @@ class OpentalentApiService implements LoggerAwareInterface
 
         try {
             if ($this->context->isDevelopment()) {
-                $this->logger->info('API Call: ' . $uri);
+                OtLogger::info('API Call: ' . $uri);
             }
             return $this->client->request($httpMethod, $uri, $options);
         } catch (GuzzleException $e) {

+ 1 - 1
ot_core/Classes/Service/OpentalentEnvService.php

@@ -18,7 +18,7 @@ class OpentalentEnvService
 {
     public static function get($varname) {
         if (!array_key_exists($varname, $GLOBALS['OT'])) {
-            throw new \RuntimeException('Unexisting OT environment variable requested: ' . $varname);
+            throw new \RuntimeException('Un-existing OT environment variable requested: ' . $varname);
         }
         return $GLOBALS['OT'][$varname];
     }

+ 2 - 2
ot_core/Classes/ViewHelpers/OtAbstractViewHelper.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtCore\ViewHelpers;
 
 use FluidTYPO3\Vhs\Utility\ErrorUtility;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
@@ -15,8 +16,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
  *
  * @package Opentalent\OtCore\ViewHelpers
  */
-class OtAbstractViewHelper  extends AbstractViewHelper implements LoggerAwareInterface {
-    use LoggerAwareTrait;
+class OtAbstractViewHelper extends AbstractViewHelper {
 
     /**
      * @var OtPageRepository

+ 2 - 2
ot_core/Classes/Website/OtWebsiteRepository.php

@@ -159,7 +159,7 @@ class OtWebsiteRepository
             $q->andWhere($q->expr()->eq('deleted', 0));
         }
         $rootUid = $q->execute()->fetchColumn(0);
-        if (!$rootUid > 0) {
+        if (!($rootUid > 0)) {
             throw new NoSuchRecordException('No root page found for website ' . $websiteUid);
         }
         return $rootUid;
@@ -237,7 +237,7 @@ class OtWebsiteRepository
      */
     public function generateWebsiteConfiguration(array $website, string $identifier = null): Site
     {
-        $rootUid = $this->getWebsiteRootUid($website['uid']);
+        $rootUid = $this->getWebsiteRootUid($website['uid'], false);
 
         $identifier = $identifier ?? $website['config_identifier'];
 

+ 0 - 6
ot_core/Configuration/ot_config.yaml

@@ -1,6 +0,0 @@
-
-# Variant Uri for development purposes
-api_variant_uri:
-  preprod.opentalent.fr: https://api.preprod.opentalent.fr/api/
-  local.sub.opentalent.fr: http://nginx/api/
-  typo3: http://nginx/api/

+ 1 - 1
ot_core/Tests/Unit/Domain/Repository/MemberRepositoryTest.php

@@ -18,7 +18,7 @@ class MemberRepositoryTest extends AbstractApiRepositoryTestCase
     public function findByOrganizationId() {
         $organization_id = 1;
 
-        $expected_uri = "api/public/members?_format=json&filter%5Bwhere%5D%5BorganizationId%5D=1&itemsPerPage=200";
+        $expected_uri = "api/public/members?_format=json&filter%5Bwhere%5D%5BorganizationId%5D=1&itemsPerPage=20000";
         $this->injectClientFor($expected_uri);
 
         $actual = $this->repository->findByOrganizationId($organization_id);

+ 2 - 2
ot_core/Tests/Unit/Fixtures/ApiResponseFixtures.php

@@ -182,8 +182,8 @@ class ApiResponseFixtures
         'api/public/events?_format=json&organizationId=1&itemsPerPage=1&filter%5Bwhere%5D%5BdatetimeStart%5D%5Bgte%5D=2021-01-01T00%3A00%3A00%2B00%3A00&filter%5Bwhere%5D%5BdatetimeEnd%5D%5Blte%5D=2021-01-31T00%3A00%3A00%2B00%3A00&filter%5Border%5D%5B0%5D%5BdatetimeStart%5D=ASC&children=1' => 'event',
         'api/public/donors?_format=json&organizationId=1&page=1&itemsPerPage=99' => 'donor',
         'api/public/donors?_format=json&organizationId=1&parent=1&page=1&itemsPerPage=99' => 'donor',
-        'api/public/members?_format=json&filter%5Bwhere%5D%5BorganizationId%5D=1&itemsPerPage=200' => 'member',
-        'api/public/members_ca?_format=json&filter%5Bwhere%5D%5BorganizationId%5D=1&itemsPerPage=200' => 'member'
+        'api/public/members?_format=json&filter%5Bwhere%5D%5BorganizationId%5D=1&itemsPerPage=20000' => 'member',
+        'api/public/members_ca?_format=json&filter%5Bwhere%5D%5BorganizationId%5D=1&itemsPerPage=20000' => 'member'
     ];
 
     public function get($url): HtmlResponse

+ 1 - 1
ot_core/ext_emconf.php

@@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.6.3',
+    'version' => '0.6.4',
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 2 - 2
ot_core/ext_localconf.php

@@ -5,7 +5,7 @@ if (!defined('TYPO3_MODE')) {
 }
 
 $GLOBALS['TYPO3_CONF_VARS']['LOG']['Opentalent']['OtCore']['writerConfiguration'] = [
-    // configuration for ERROR level log entries
+    // configuration for DEBUG level log entries
     TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
         // add a FileWriter
         TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
@@ -34,7 +34,7 @@ $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Controller/NewsController.php']['cre
 // ** Opentalent environment variables **
 // An array containing all or part of these variables could have been set before, for example
 // in the AdditionalConfiguration.php file.
-// In this case we merge them so the pre-defined vars are not overridden.
+// In this case we merge them so that the pre-defined vars are not overridden.
 // (/!\ do not forget to clear the cache after any update here)
 $GLOBALS['OT'] = array_merge([
     'API_BASE_URI' => 'https://api.opentalent.fr',

+ 1 - 1
ot_optimizer/ext_emconf.php

@@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '1.0.0',
+    'version' => '1.0.0',  //see ot_core/ext_emconf.php to get the current ot extensions version
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 1 - 1
ot_stats/ext_emconf.php

@@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '1.0.0',
+    'version' => '1.0.0',  //see ot_core/ext_emconf.php to get the current ot extensions version
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 3 - 2
ot_templating/Classes/ViewHelpers/Donors/GetAllViewHelper.php

@@ -5,6 +5,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Donors;
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
 use Opentalent\OtCore\Domain\Repository\DonorRepository;
 use Opentalent\OtCore\Exception\ApiRequestException;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 
 /**
@@ -81,7 +82,7 @@ class GetAllViewHelper extends OtAbstractViewHelper {
             try {
                 $donors = $this->donorRepository->findParentsByOrganizationId($organizationId);
             } catch (ApiRequestException $e) {
-                $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+                OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
                 $donors = [];
             }
         } else {
@@ -89,7 +90,7 @@ class GetAllViewHelper extends OtAbstractViewHelper {
             try {
                 $donors = $this->donorRepository->findByOrganizationId($organizationId);
             } catch (ApiRequestException $e) {
-                $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+                OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
                 $donors = [];
             }
         }

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

@@ -4,6 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Events;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
 use Opentalent\OtCore\Domain\Repository\ApiPagedCollection;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Domain\Repository\EventRepository;
 use Opentalent\OtCore\Exception\ApiRequestException;
@@ -105,8 +106,7 @@ class GetAllViewHelper extends OtAbstractViewHelper {
         try {
             $events = $this->eventRepository->searchBy($organizationId, $searchParams);
         } catch (ApiRequestException $e) {
-            var_dump($e);die;
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $events = new ApiPagedCollection(0, 0, 1, []);
         }
         $variables = [$as => $events];

+ 2 - 1
ot_templating/Classes/ViewHelpers/Events/GetByIdViewHelper.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Events;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Domain\Model\Event;
 use Opentalent\OtCore\Domain\Repository\EventRepository;
@@ -70,7 +71,7 @@ class GetByIdViewHelper extends OtAbstractViewHelper {
         try {
             $event = $this->eventRepository->findById($eventId);
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $event = new Event();
             $event->setName("<Erreur>");
             $event->setDescription("Une erreur s'est produite et ne permet pas l'affichage de cet évènement. Veuillez nous excusez pour la gêne occasionnée.");

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

@@ -3,6 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Events;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Domain\Repository\EventRepository;
 use Opentalent\OtCore\Exception\ApiRequestException;
@@ -136,7 +137,7 @@ class GetNextViewHelper extends OtAbstractViewHelper {
                 $events = $this->eventRepository->findByOrganizationId($organizationId, $fromDate, $toDate, $limit);
             }
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $events = [];
         }
 

+ 14 - 14
ot_templating/Classes/ViewHelpers/Members/GetAllCaViewHelper.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Members;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
 use Opentalent\OtCore\Domain\Repository\MemberCaRepository;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Exception\ApiRequestException;
 
@@ -40,7 +41,7 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
      * -- This method is expected by Fluid --
      * Declares the viewhelper's parameters
      */
-    public function initializeArguments()
+    public function initializeArguments(): void
     {
         $this->registerArgument(
             'as',
@@ -69,9 +70,8 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
      * Renders the content as html
      *
      * @return string
-     * @throws \GuzzleHttp\Exception\GuzzleException
      */
-    public function render()
+    public function render(): string
     {
         // Get current settings
         $as = $this->arguments['as'];
@@ -103,24 +103,24 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
             $collection = $this->memberCaRepository->findByOrganizationId($organizationId);
             $members = $collection->getMembers();
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $members = [];
         }
 
-        $members = array_filter($members, function($m) use ($missions) {
-            return array_search($m->getMission(), $missions) !== false;
+        $members = array_filter($members, static function($m) use ($missions) {
+            return in_array($m->getMission(), $missions, true);
         });
 
         // Sort by roles, then alphabetically by name
         usort($members,
-            function($a, $b) use ($missions) {
-                if ($a->getMission() != $b->getMission()) {
-                    $ia = array_search($a->getMission(), $missions);
-                    $ib = array_search($b->getMission(), $missions);
+            static function($a, $b) use ($missions) {
+                if ($a->getMission() !== $b->getMission()) {
+                    $ia = array_search($a->getMission(), $missions, true);
+                    $ib = array_search($b->getMission(), $missions, true);
                     return $ia - $ib;
-                } else {
-                    return strcmp($a->getName(), $b->getName());
                 }
+
+                return strcmp($a->getName(), $b->getName());
             }
         );
 
@@ -135,7 +135,7 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
             // Put members into their categories
             foreach ($members as $member) {
                 if (array_key_exists($member->getMission(), $membersByMission)) {
-                    array_push($membersByMission[$member->getMission()], $member);
+                    $membersByMission[$member->getMission()][] = $member;
                 }
             }
 
@@ -150,7 +150,7 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
     /**
      * @param MemberCaRepository $memberCaRepository
      */
-    public function injectMemberCaRepository(MemberCaRepository $memberCaRepository)
+    public function injectMemberCaRepository(MemberCaRepository $memberCaRepository): void
     {
         $this->memberCaRepository = $memberCaRepository;
     }

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

@@ -5,6 +5,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Members;
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
 use Opentalent\OtCore\Domain\Repository\MemberRepository;
 use Opentalent\OtCore\Exception\ApiRequestException;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 
 /**
@@ -82,7 +83,7 @@ class GetAllViewHelper extends OtAbstractViewHelper {
             $collection = $this->memberRepository->findByOrganizationId($organizationId);
             $members = $collection->getMembers();
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $members = [];
         }
 

+ 3 - 2
ot_templating/Classes/ViewHelpers/Members/GetPresidentViewHelper.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Members;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
 use Opentalent\OtCore\Domain\Repository\MemberCaRepository;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Domain\Repository\MemberRepository;
 use Opentalent\OtCore\Exception\ApiRequestException;
@@ -73,13 +74,13 @@ class GetPresidentViewHelper extends OtAbstractViewHelper {
             $collection = $this->memberCaRepository->findByOrganizationId($organizationId);
             $members = $collection->getMembers();
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $members = [];
         }
 
         $president = null;
         foreach ($members as $member) {
-            if ($member->getMission() == 'PRESIDENT') {
+            if ($member->getMission() === 'PRESIDENT') {
                 $president = $member;
                 break;
             }

+ 2 - 1
ot_templating/Classes/ViewHelpers/Organizations/GetByIdViewHelper.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Organizations;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Domain\Model\Organization;
 use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
@@ -71,7 +72,7 @@ class GetByIdViewHelper extends OtAbstractViewHelper {
         try {
             $organization = $this->organizationRepository->findById($organizationId);
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $organization = new Organization();
             $organization->setName("<Erreur: impossible d'afficher le résultat>");
         }

+ 2 - 1
ot_templating/Classes/ViewHelpers/Organizations/GetChildrenViewHelper.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Organizations;
 
 use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
 use Opentalent\OtCore\Exception\ApiRequestException;
@@ -87,7 +88,7 @@ class GetChildrenViewHelper extends OtAbstractViewHelper {
                 $page
             );
         } catch (ApiRequestException $e) {
-            $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
+            OtLogger::error(sprintf('API Error: %s', $e->getMessage()));
             $organizations = [];
         }
 

+ 1 - 0
ot_templating/Configuration/TypoScript/constants.txt

@@ -23,6 +23,7 @@ plugin.tx_ottemplating {
             twitter =
             facebook =
             instagram =
+            youtube =
         }
         network {
             # >> Ces paramètres doivent être redéfinis dans le gabarit du site

+ 9 - 0
ot_templating/Configuration/TypoScript/setup.txt

@@ -84,6 +84,7 @@ plugin.tx_ottemplating {
         structureFacebook = {$plugin.tx_ottemplating.settings.organization.facebook}
         structureTwitter = {$plugin.tx_ottemplating.settings.organization.twitter}
         structureInstagram = {$plugin.tx_ottemplating.settings.organization.instagram}
+        structureYoutube = {$plugin.tx_ottemplating.settings.organization.youtube}
         structureIsNetwork = {$plugin.tx_ottemplating.settings.organization.is_network}
         networkLogo = {$plugin.tx_ottemplating.settings.network.logo}
         networkName = {$plugin.tx_ottemplating.settings.network.name}
@@ -223,3 +224,11 @@ lib.tx_ottemplating.widgets {
         }
     }
 }
+
+## hCaptcha
+plugin.tx_hcaptcha {
+  settings {
+    publicKey = a35a22e0-6127-4905-817c-3f8b7c7e49e8
+    privateKey = 0x459461d6f52061d3b79eF603F2BcA30497e949c7
+  }
+}

+ 7 - 0
ot_templating/Resources/Private/Forms/Contact.form.yaml

@@ -160,3 +160,10 @@ renderables:
           text: 'By submitting this form, you agree that theses informations can be processed in order to contact you back and answer your demand'
           elementClassAttribute: 'contact-form-info'
         label: ''
+      -
+        validators:
+          -
+            identifier: Hcaptcha
+        type: Hcaptcha
+        identifier: hcaptcha-1
+        label: hCaptcha

+ 8 - 0
ot_templating/Resources/Private/Partials/Classic/Footer.html

@@ -47,6 +47,14 @@
                 </a>
             </li>
         </f:if>
+
+        <f:if condition="{settings.structureYoutube} != ''">
+            <li class="social-logo">
+                <a href="{ot:utilities.absoluteUrl(url: settings.structureYoutube)}" target="_blank">
+                    <i class="fab fa-youtube" style="color: #f2f2f2"></i>
+                </a>
+            </li>
+        </f:if>
     </ul>
 
     <div class="logo-ot">

+ 4 - 4
ot_templating/Resources/Private/Partials/Modern/Carousel.html

@@ -11,15 +11,14 @@
                     countAs="count">
 
     <f:if condition="{count} > 0">
-
         <section id="main-carousel" class="rev-slider">
             <div id="rev_slider_268_1_wrapper"
                  class="rev_slider_wrapper fullwidthbanner-container"
                  data-alias="webster-slider-2"
                  data-source="gallery"
-                 style="margin:0px auto;background:transparent;padding:0px;margin-top:0px;margin-bottom:0px;">
+                 style="margin:0 auto;padding:0;background:transparent;">
 
-                <f:if condition="{count} <= 1">
+                <f:if condition="{count} === 1">
                     <style>
                         .tparrows {
                             display: none !important;
@@ -44,7 +43,8 @@
                                 data-easeout="default"
                                 data-masterspeed="1000"
                                 data-thumb=""
-                                data-rotate="0"  data-saveperformance="off"
+                                data-rotate="0"
+                                data-saveperformance="off"
                                 data-title="Slide"
                                 data-param1=""
                                 data-param2=""

+ 8 - 0
ot_templating/Resources/Private/Partials/Modern/Footer.html

@@ -82,6 +82,14 @@
                         </a>
                     </li>
                 </f:if>
+
+                <f:if condition="{settings.structureYoutube} != ''">
+                    <li class="social-logo">
+                        <a href="{ot:utilities.absoluteUrl(url: settings.structureYoutube)}" target="_blank">
+                            <i class="fa fa-youtube"></i> Youtube
+                        </a>
+                    </li>
+                </f:if>
             </ul>
         </div>
     </f:if>

+ 4 - 5
ot_templating/Resources/Private/Templates/Content/Carousel.html

@@ -22,7 +22,6 @@
 
             <flux:field.input name="width" eval="trim" default="600" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:width_in_pixels"/>
             <flux:field.input name="height" eval="trim" default="400" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:height_in_pixels"/>
-            <flux:field.checkbox name="crop" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:crop_large_images" default="0"/>
 
             <flux:field.inline.fal name="images" minItems="2" maxItems="24"/>
 
@@ -53,18 +52,18 @@
     <f:section name="Main">
 
         <div class="center-carousel">
-            <div class="carousel" style="max-width:{width}px; max-height:{height}px">
+            <div class="carousel" style="max-width:{width}px; max-height:{height}px;">
                 <f:for each="{v:content.resources.fal(field: 'images', record: '{record}')}"
                        as="image"
                        iteration="iterator">
-                    <div style="height: {height}px">
+                    <div style="display: flex;flex-direction: row;justify-content: center;align-items: center;height:100%;width:{width}px;height:{height}px;">
                         <f:image treatIdAsReference="1"
                                  src="{image.id}"
                                  title="{image.title}"
                                  alt="{image.alternative}"
                                  class="carousel-img"
-                                 width="{width}"
-                                 maxHeight="{height}{f:if(condition: crop, then: 'c')}"
+                                 height="{height}"
+                                 style="max-width:{width}px;max-height:{height}px;width:auto;height:auto;"
                         />
                     </div>
                 </f:for>

+ 1 - 1
ot_templating/ext_emconf.php

@@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '1.0.0',
+    'version' => '1.0.0',  //see ot_core/ext_emconf.php to get the current ot extensions version
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',