Olivier Massot 4 лет назад
Родитель
Сommit
8010c6840d
24 измененных файлов с 137 добавлено и 33 удалено
  1. 2 2
      ot_admin/ext_emconf.php
  2. 1 1
      ot_connect/ext_emconf.php
  3. 31 5
      ot_core/Classes/Cache/OtCacheManager.php
  4. 1 1
      ot_core/Classes/Domain/Repository/EventRepository.php
  5. 9 2
      ot_core/Classes/Website/OtWebsiteRepository.php
  6. 2 2
      ot_core/Tests/Unit/Domain/Repository/DonorRepositoryTest.php
  7. 2 2
      ot_core/Tests/Unit/Fixtures/ApiResponseFixtures.php
  8. 2 2
      ot_core/ext_emconf.php
  9. 13 2
      ot_optimizer/Classes/Middleware/Frontend/OtPageResolver.php
  10. 2 2
      ot_optimizer/ext_emconf.php
  11. 2 2
      ot_stats/ext_emconf.php
  12. 3 0
      ot_templating/Classes/Controller/OtCustomizerController.php
  13. 3 0
      ot_templating/Classes/ViewHelpers/Events/GetAllViewHelper.php
  14. 7 1
      ot_templating/Classes/ViewHelpers/Events/GetByIdViewHelper.php
  15. 19 1
      ot_templating/Classes/ViewHelpers/EventsPage/GetIdViewHelper.php
  16. 1 1
      ot_templating/Resources/Private/Partials/Classic/Donors.html
  17. 11 1
      ot_templating/Resources/Private/Partials/Classic/NextEvents.html
  18. 1 1
      ot_templating/Resources/Private/Partials/Modern/Donors.html
  19. 1 1
      ot_templating/Resources/Private/Templates/Content/Carousel.html
  20. 1 1
      ot_templating/Resources/Private/Templates/Content/Faq.html
  21. 7 0
      ot_templating/Resources/Private/Templates/OtCustomizer/Index.html
  22. 0 1
      ot_templating/Resources/Private/Templates/Page/Home.html
  23. 14 0
      ot_templating/Resources/Public/assets/Modern/style/custom.css
  24. 2 2
      ot_templating/ext_emconf.php

+ 2 - 2
ot_admin/ext_emconf.php

@@ -14,11 +14,11 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'services',
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
-    'state' => 'alpha',
+    'state' => 'stable',
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.1.0',
+    'version' => '1.0.0',
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 1 - 1
ot_connect/ext_emconf.php

@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'services',
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
-    'state' => 'alpha',
+    'state' => 'stable',
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,

+ 31 - 5
ot_core/Classes/Cache/OtCacheManager.php

@@ -3,10 +3,9 @@
 namespace Opentalent\OtCore\Cache;
 
 use Opentalent\OtCore\Website\OtPageRepository;
-use TYPO3\CMS\Core\Service\OpcodeCacheService;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Install\Service\ClearCacheService;
 use TYPO3\CMS\Core\Cache\CacheManager;
 
 class OtCacheManager
@@ -30,7 +29,7 @@ class OtCacheManager
      * @param int $pageUid
      * @param bool $clearAll if true, all caches will be cleared, and not only the frontend one
      */
-    public static function clearSiteCache(int $pageUid, $clearAll=false) {
+    public static function clearSiteCache(int $pageUid, bool $clearAll = false) {
 
         $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
         $rootPage = $pageRepository->getRootPageFor($pageUid);
@@ -43,10 +42,37 @@ class OtCacheManager
             return 'pageId_' . $page['uid'];
         }, $pages);
 
-        if (!$clearAll) {
+        if ($clearAll) {
+            $cacheManager->flushCachesByTags($tags);
+        } else {
             $cacheManager->flushCachesInGroupByTags('pages', $tags);
+        }
+
+        // << BUGFIX: without this, the fluid templates caches are not cleared
+        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
+        $cnn = $connectionPool->getConnectionByName('Default');
+        $cnn->beginTransaction();
+        $sql = "update typo3.cache_hash h inner join typo3.cache_hash_tags t on h.id = t.id
+                set h.expires = 0
+                where t.tag = 'ident_TS_TEMPLATE';";
+        $stmt = $cnn->prepare($sql);
+        $stmt->executeQuery();
+        $cnn->commit();
+        // >>
+    }
+
+    /**
+     * Clears cache
+     *
+     * @param bool $clearAll if true, all caches will be cleared, and not only the frontend one
+     */
+    public static function clearCache($clearAll) {
+        $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
+
+        if ($clearAll) {
+            $cacheManager->flushCachesInGroup('pages');
         } else {
-            $cacheManager->flushCachesByTags($tags);
+            $cacheManager->flushCaches();
         }
     }
 

+ 1 - 1
ot_core/Classes/Domain/Repository/EventRepository.php

@@ -18,7 +18,7 @@ class EventRepository extends BaseApiRepository
      * @return object Event
      * @throws ApiRequestException
      */
-    public function findById(int $id): object
+    public function findById(int $id)
     {
         $params = ["filter[where][id]" => $id];
         return $this->getApiFirstRecord($params);

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

@@ -333,7 +333,7 @@ class OtWebsiteRepository
      * @return Site
      * @throws NoSuchWebsiteException
      */
-    public function matchUriToWebsite(\Psr\Http\Message\UriInterface $uri, bool $devMode=false): array
+    public function matchUriToWebsite(\Psr\Http\Message\UriInterface $uri, bool $devMode=false, bool $withRestrictions = true): array
     {
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
 
@@ -356,6 +356,10 @@ class OtWebsiteRepository
             }
         }
 
+        if ($withRestrictions) {
+            $q = $q->andWhere($queryBuilder->expr()->eq('deleted', 0));
+        }
+
         $website = $q->execute()
                     ->fetch();
 
@@ -373,7 +377,7 @@ class OtWebsiteRepository
      * @return int
      * @throws NoSuchWebsiteException
      */
-    public function matchUriToPage(array $otWebsite, UriInterface $uri, bool $devMode=false): int
+    public function matchUriToPage(array $otWebsite, UriInterface $uri, bool $devMode=false, bool $withRestrictions = true): int
     {
         $tail = $uri->getPath();
         if ($devMode) {
@@ -384,6 +388,9 @@ class OtWebsiteRepository
         }
 
         $q = $this->connectionPool->getQueryBuilderForTable('pages');
+        if (!$withRestrictions) {
+            $q->getRestrictions()->removeAll();
+        }
         return $q
             ->select('uid')
             ->from('pages')

+ 2 - 2
ot_core/Tests/Unit/Domain/Repository/DonorRepositoryTest.php

@@ -18,7 +18,7 @@ class DonorRepositoryTest extends AbstractApiRepositoryTestCase
     public function findByOrganizationId() {
         $organization_id = 1;
 
-        $expected_uri = "api/public/donors?_format=json&organizationId=1&page=1&itemsPerPage=8";
+        $expected_uri = "api/public/donors?_format=json&organizationId=1&page=1&itemsPerPage=99";
         $this->injectClientFor($expected_uri);
 
         $actual = $this->repository->findByOrganizationId($organization_id);
@@ -34,7 +34,7 @@ class DonorRepositoryTest extends AbstractApiRepositoryTestCase
     public function findParentsByOrganizationId() {
         $organization_id = 1;
 
-        $expected_uri = "api/public/donors?_format=json&organizationId=1&parent=1&page=1&itemsPerPage=8";
+        $expected_uri = "api/public/donors?_format=json&organizationId=1&parent=1&page=1&itemsPerPage=99";
         $this->injectClientFor($expected_uri);
 
         $actual = $this->repository->findParentsByOrganizationId($organization_id);

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

@@ -180,8 +180,8 @@ class ApiResponseFixtures
         'api/public/events?_format=json&organizationId=1&page=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' => 'event',
         'api/public/events?_format=json&organizationId=1&page=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&parent=1' => 'event',
         '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=8' => 'donor',
-        'api/public/donors?_format=json&organizationId=1&parent=1&page=1&itemsPerPage=8' => 'donor',
+        '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'
     ];

+ 2 - 2
ot_core/ext_emconf.php

@@ -14,11 +14,11 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'services',
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
-    'state' => 'alpha',
+    'state' => 'stable',
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.1.0',
+    'version' => '0.6.2',
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 13 - 2
ot_optimizer/Classes/Middleware/Frontend/OtPageResolver.php

@@ -27,7 +27,9 @@ class OtPageResolver extends \TYPO3\CMS\Frontend\Middleware\PageResolver
      */
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
     {
-        $shallFallback = $_COOKIE['optimize'] != 1 && $_SERVER['TYPO3_OPTIMIZE'] != 1;
+        // Shall fallback on non-optimized mode if a cookie 'optimize' exists and is different from 1, or if
+        // a server global variable TYPO3_OPTIMIZE is set and is different from 1
+        $shallFallback = ($_COOKIE['optimize'] != 1 && $_SERVER['TYPO3_OPTIMIZE'] != 1);
         if ($shallFallback) {
             return parent::process($request, $handler);
         }
@@ -54,7 +56,16 @@ class OtPageResolver extends \TYPO3\CMS\Frontend\Middleware\PageResolver
             );
         }
 
-        $pageUid = $otWebsiteRepository->matchUriToPage($website, $request->getUri(), $devMode);
+        // if the page is requested from the BE module Viewpage or FrontendEditing, it shall be displayed even if hidden
+        // a backend user shall be authenticated for this
+        $requestedFromBE = preg_match(
+            "/.+\/typo3\/index.php\?route=.*(Viewpage)|(FrontendEditing).*/",
+            $_SERVER['HTTP_REFERER']
+            )
+            && $GLOBALS['BE_USER'];
+
+        $pageUid = $otWebsiteRepository->matchUriToPage($website, $request->getUri(), $devMode, !$requestedFromBE);
+
         if (!$pageUid > 0) {
             return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
                 $request,

+ 2 - 2
ot_optimizer/ext_emconf.php

@@ -14,11 +14,11 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'services',
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
-    'state' => 'alpha',
+    'state' => 'stable',
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.1.0',
+    'version' => '1.0.0',
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 2 - 2
ot_stats/ext_emconf.php

@@ -14,11 +14,11 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'services',
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
-    'state' => 'alpha',
+    'state' => 'stable',
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.1.0',
+    'version' => '1.0.0',
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',

+ 3 - 0
ot_templating/Classes/Controller/OtCustomizerController.php

@@ -82,6 +82,9 @@ class OtCustomizerController extends SelectedSiteController {
         if (isset($args['displayBreadcrumb'])) {
             $prefs['displayBreadcrumb'] = $args['displayBreadcrumb'] ? 1 : 0;
         }
+        if (isset($args['staticDonors'])) {
+            $prefs['staticDonors'] = $args['staticDonors'] ? 1 : 0;
+        }
 
         // applies the change in the database
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');

+ 3 - 0
ot_templating/Classes/ViewHelpers/Events/GetAllViewHelper.php

@@ -98,6 +98,9 @@ class GetAllViewHelper extends OtAbstractViewHelper {
         if ($fromChildren) {
             $searchParams['children'] = '1';
         }
+        if ($_REQUEST['page']) {
+            $searchParams['page'] = $_REQUEST['page'];
+        }
 
         try {
             $events = $this->eventRepository->searchBy($organizationId, $searchParams);

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

@@ -72,9 +72,15 @@ class GetByIdViewHelper extends OtAbstractViewHelper {
         } catch (ApiRequestException $e) {
             $this->logger->error(sprintf('API Error: %s', $e->getMessage()));
             $event = new Event();
-            $event->setName("<Erreur: impossible d'afficher l'évènement>");
+            $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.");
         }
+
+        if ($event === null) {
+            $event = new Event();
+            $event->setName("(Évènement supprimé)");
+        }
+
         $variables = [$as => $event];
         return $this->renderChildrenWithVariables($variables);
     }

+ 19 - 1
ot_templating/Classes/ViewHelpers/EventsPage/GetIdViewHelper.php

@@ -24,6 +24,20 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GetIdViewHelper extends OtAbstractViewHelper
 {
+    /**
+     * -- This method is expected by Fluid --
+     * Declares the viewhelper's parameters
+     */
+    public function initializeArguments()
+    {
+        $this->registerArgument(
+            'children',
+            'integer',
+            'If true, look for the events page of the children structures, instead of the current one',
+            false,
+            0
+        );
+    }
 
     /**
      *  -- This method is expected by Fluid --
@@ -48,8 +62,12 @@ class GetIdViewHelper extends OtAbstractViewHelper
 
         $subpages = $pageRepository->getAllSubpagesForPage($rootId);
 
+        $templateName = $arguments['children'] == 1 ?
+            'OpenTalent.OtTemplating->structuresEvents' :
+            'OpenTalent.OtTemplating->events';
+
         foreach ($subpages as $page) {
-            if ($page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->events'
+            if ($page['tx_fed_page_controller_action'] === $templateName
                 & $page['deleted'] == 0
                 & $page['hidden'] == 0
             ) {

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

@@ -22,7 +22,7 @@
 
                 </header>
                 <div class="box-content">
-                    <div class="donor-list {f:if(condition: '{settings.staticDonors}==0', then: 'carousel')}">
+                    <div class="donor-list {f:if(condition: '{ot:template.getPreference(key: \'staticDonors\')}!=1', then: 'carousel')}">
                         <f:for each="{donorsCollection.members}" as="donor">
                             <div class="donor-card">
                                 <a href="{ot:utilities.absoluteUrl(url: donor.website)}" target="_blank">

+ 11 - 1
ot_templating/Resources/Private/Partials/Classic/NextEvents.html

@@ -5,6 +5,7 @@
 
 <f:comment><!-- Get the events page' uid if the page is found --></f:comment>
 <v:variable.set value="{ot:eventsPage.getId()}" name="eventsPageUid"/>
+<v:variable.set value="{ot:eventsPage.getId(children: 1)}" name="childrenEventsPageUid"/>
 
 <div class="ot-box ot-events">
     <div class="events-list">
@@ -94,9 +95,18 @@
         </ot:events.getNext>
 
         <footer>
-            <f:if condition="{fromParents}||{fromChildren}">
+            <f:if condition="{fromParents}">
                 <f:then>
                 </f:then>
+                <f:else if="{fromChildren}">
+                    <f:if condition="{childrenEventsPageUid} > 0"><f:then>
+                        <div class="event-see-all">
+                            <f:link.page pageUid="{childrenEventsPageUid}">
+                                <f:translate key="see-all-events"/>
+                            </f:link.page>
+                        </div>
+                    </f:then></f:if>
+                </f:else>
                 <f:else>
                     <f:if condition="{eventsPageUid} > 0"><f:then>
                         <div class="event-see-all">

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

@@ -28,7 +28,7 @@
                     </div>
                     <div class="col-lg-12 col-md-12">
                         <div class="clients-list partners-list grayscale">
-                            <div class="{f:if(condition: '{settings.staticDonors}==0', then: 'owl-carousel')}"
+                            <div class="{f:if(condition: '{ot:template.getPreference(key: \'staticDonors\')}!=1', then: 'owl-carousel', else: 'static')}"
                                  data-nav-dots="false"
                                  data-md-items="4"
                                  data-sm-items="3"

+ 1 - 1
ot_templating/Resources/Private/Templates/Content/Carousel.html

@@ -22,7 +22,7 @@
 
             <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.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"/>
 

+ 1 - 1
ot_templating/Resources/Private/Templates/Content/Faq.html

@@ -23,7 +23,7 @@
                 <flux:form.object name="item" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:question">
                     <flux:field.input name="question" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:question"/>
                     <flux:field.text name="reponse" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:answer" defaultExtras="richtext[]:rte_transform[mode=ts_css]"/>
-                    <flux:field.checkbox name="open" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:unfolded ?"/>
+                    <flux:field.checkbox name="open" label="LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:unfolded"/>
                 </flux:form.object>
             </flux:form.section>
         </flux:form>

+ 7 - 0
ot_templating/Resources/Private/Templates/OtCustomizer/Index.html

@@ -79,6 +79,13 @@
                                      checked="{preferences.displayBreadcrumb}"
                     />
                 </div>
+                <div class="form-group">
+                    <label><f:translate key="static_donors"/></label>
+                    <f:form.checkbox name="staticDonors"
+                                     value="3"
+                                     checked="{preferences.staticDonors}"
+                    />
+                </div>
 
                 <div class="actions">
                     <f:form.button type="submit" class="ot-btn">

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

@@ -7,7 +7,6 @@
 
 <f:section name='Configuration'>
     <flux:form id="home" label="LLL:template_home" extensionName="Opentalent.OtTemplating">
-        <flux:field.checkbox name="settings.staticDonors" label="LLL:static_donors" default="0"/>
         <flux:field.input name="settings.eventsLimit" label="LLL:next_events_limit" default="5" minimum="1" maximum="24" eval="int"/>
         <flux:field.input name="settings.eventsPeriod" label="LLL:next_events_period" default="8" minimum="0" eval="int"/>
     </flux:form>

+ 14 - 0
ot_templating/Resources/Public/assets/Modern/style/custom.css

@@ -58,6 +58,9 @@
         flex: 1;
     }
 
+    .frame {
+        margin-bottom: 24px;
+    }
 
     /*------------------------
         Barre réseau
@@ -306,6 +309,17 @@
         Partenaires
     ------------------------*/
 
+    .partners-list > .static {
+        display: flex;
+        flex-direction: row;
+        justify-content: center;
+        flex-wrap: wrap;
+    }
+
+    .partners-list > .static .item {
+        margin: 0 3px;
+    }
+
     .partners-list img {
         max-height: 80px;
     }

+ 2 - 2
ot_templating/ext_emconf.php

@@ -14,11 +14,11 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'templates',
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
-    'state' => 'alpha',
+    'state' => 'stable',
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.2.0',
+    'version' => '1.0.0',
     'constraints' => [
         'depends' => [
             'typo3' => '8.7.0-10.4.99',