瀏覽代碼

Merge branch 'release/0.6.3b2'

Olivier Massot 4 年之前
父節點
當前提交
77ae3e640d

+ 1 - 30
README.md

@@ -2,36 +2,7 @@
 | --- | --- |
 | ot_core | [![pipeline status](http://gitlab.2iopenservice.com/opentalent/ot_typo3/badges/unittests/pipeline.svg)](http://gitlab.2iopenservice.com/opentalent/ot_typo3/-/commits/unittests) [![coverage report](http://gitlab.2iopenservice.com/opentalent/ot_typo3/badges/unittests/coverage.svg)](http://gitlab.2iopenservice.com/opentalent/ot_typo3/-/commits/unittests) |
 
-**[Voir la documentation](/doc/index.md)**
-
 ## Opentalent extensions for Typo3
 
-### Pré-requis:
-
-* php 7.4
-* Typo3 v10.4 (en mode composer)
-
-### Les extensions
-
-Pour plus d'information sur chaque extension, consultez les readme de chacune d'elles. 
-
-### Pour les installer
-
-1. Copier les répertoires des extensions dans le sous-répertoire `public/typo3conf/ext/` du répertoire de l'application typo3
-2. Ajouter les lignes suivantes au fichier `composer.json` de l'application :
-
-    	"autoload": {
-    		"psr-4": {
-                "Opentalent\\OtCore\\": "public/typo3conf/ext/ot_core/Classes",
-                "Opentalent\\OtConnect\\": "public/typo3conf/ext/ot_connect/Classes",
-                "Opentalent\\OtTemplating\\": "public/typo3conf/ext/ot_templating/Classes",
-                "Opentalent\\OtStats\\": "public/typo3conf/ext/ot_stats/Classes",
-                "Opentalent\\OtAdmin\\": "public/typo3conf/ext/ot_admin/Classes",
-                "Opentalent\\OtOptimizer\\": "public/typo3conf/ext/ot_optimizer/Classes"
-    		}
-    	}
-
-3. Faire un 'dump autoload':
-
-    composer dumpautoload
+**[Voir la documentation](/doc/index.md)**
 

+ 16 - 0
doc/env.md

@@ -0,0 +1,16 @@
+# Gestion des variables d'environnement
+
+Les variables d'environnement (url de l'API, adresse de login...) sont gérées sous formes de variables
+globales, stockées dans une array:
+
+    $GLOBALS['OT'] = ['MY_VAR' => 1, ...]
+
+Cette array est d'abord définie dans le fichier ot_core/ext_localconf.php
+
+Les différentes valeurs peuvent ensuite être remplacées dans un environnement précis, en redéfinissant 
+ces variables dans le fichier typo3/public/typo3conf/AdditionalConfiguration.php
+
+Exemple:
+
+    $GLOBALS['OT']['API_BASE_URI'] = 'http://docker.nginx.opentalent.fr';
+

+ 9 - 8
doc/index.md

@@ -23,14 +23,15 @@ plus environ 2000 sites archivés.
 #### Concepts et principes amenés par les extensions
 
 1. [Le concept de Websites](ot_websites.md)
-2. [Fonctionnement attendu de l'authentification et mise en oeuvre](auth.md)
-3. [Droits des administrateurs / éditeurs et mise en oeuvre](be_users.md)
-4. [Système de templating](templating.md)
-5. [Les formulaires](forms.md)
-6. [Reception des hooks depuis le logiciel](hooks.md)
-7. [Routage et optimisation](routing.md)
-8. [Intégration des réseaux sociaux](social_networks.md)
-9. [Statistiques d'utilisation des sites](stats.md)
+2. [Les variables d'environnement](env.md)
+3. [Fonctionnement attendu de l'authentification et mise en oeuvre](auth.md)
+4. [Droits des administrateurs / éditeurs et mise en oeuvre](be_users.md)
+5. [Système de templating](templating.md)
+6. [Les formulaires](forms.md)
+7. [Reception des hooks depuis le logiciel](hooks.md)
+8. [Routage et optimisation](routing.md)
+9. [Intégration des réseaux sociaux](social_networks.md)
+10. [Statistiques d'utilisation des sites](stats.md)
 
 #### Historique
 

+ 5 - 15
ot_core/Classes/Service/OpentalentEnvService.php

@@ -2,15 +2,13 @@
 
 namespace Opentalent\OtCore\Service;
 
-use http\Exception\RuntimeException;
-
 /**
- * Return the current opentalent environment variables
+ * Manage the opentalent environment variables
  *
  * To override the default values for a specific environment, set the new values as
  * global variables as $GLOBALS['OT']['YOUR_VAR']
  *
- * A goot place to do that is in the AdditionalConfiguration.php file of your typo3 installation,
+ * A good place to do that is in the AdditionalConfiguration.php file of your typo3 installation,
  * by adding for example:
  *
  *     $GLOBALS['OT']['DB_HOST'] = 'db';
@@ -18,18 +16,10 @@ use http\Exception\RuntimeException;
  */
 class OpentalentEnvService
 {
-    const DEFAULT = [
-        'API_BASE_URI' => 'https://api.opentalent.fr',
-        'DB_HOST' => 'prod-back',
-        'DB_USER' => 'dbcloner',
-        'DB_PASSWORD' => 'wWZ4hYcrmHLW2mUK',
-        'FRAMES_BASE_URI' => 'https://frames.opentalent.fr'
-    ];
-
     public static function get($varname) {
-        if (!array_key_exists($varname, self::DEFAULT)) {
-            throw new \RuntimeException('Unexisting environment variable requested: ' . $varname);
+        if (!array_key_exists($varname, $GLOBALS['OT'])) {
+            throw new \RuntimeException('Unexisting OT environment variable requested: ' . $varname);
         }
-        return $GLOBALS['OT'][$varname] ?? self::DEFAULT[$varname];
+        return $GLOBALS['OT'][$varname];
     }
 }

+ 0 - 6
ot_core/Tests/Unit/Service/OpentalentEnvServiceTest.php

@@ -14,13 +14,7 @@ class OpentalentEnvServiceTest extends UnitTestCase
      * @test
      */
     public function get() {
-        $this->assertEquals('https://api.opentalent.fr', OpentalentEnvService::get('API_BASE_URI'));
-        $this->assertEquals('prod-back', OpentalentEnvService::get('DB_HOST'));
-        $this->assertEquals('dbcloner', OpentalentEnvService::get('DB_USER'));
-        $this->assertEquals('wWZ4hYcrmHLW2mUK', OpentalentEnvService::get('DB_PASSWORD'));
-
         $GLOBALS['OT']['API_BASE_URI'] = 'https://local.api.opentalent.fr';
-
         $this->assertEquals('https://local.api.opentalent.fr', OpentalentEnvService::get('API_BASE_URI'));
     }
 }

+ 17 - 0
ot_core/ext_localconf.php

@@ -30,3 +30,20 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Backend\Middleware\Backe
 
 
 $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Controller/NewsController.php']['createDemandObjectFromSettings'] = ['Opentalent\OtTemplating\News\NewsFilter->createDemandObjectFromSettings'];
+
+// ** 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.
+// (/!\ do not forget to clear the cache after any update here)
+$GLOBALS['OT'] = array_merge([
+    'API_BASE_URI' => 'https://api.opentalent.fr',
+    'DB_HOST' => 'prod-back',
+    'DB_USER' => 'dbcloner',
+    'DB_PASSWORD' => 'wWZ4hYcrmHLW2mUK',
+    'FRAMES_BASE_URI' => 'https://frames.opentalent.fr',
+    'WEBSITE' => 'https://opentalent.fr',
+    'DASHBOARD_URL' => 'https://admin.opentalent.fr/#/dashboard',
+    'LOGIN_PAGE_URL' => 'https://admin.opentalent.fr/#/login',
+    'FILE_STORAGE_URL' => 'https://api.opentalent.fr/app.php/_internal/secure/files/'
+], ($GLOBALS['OT'] ?? []));

+ 3 - 3
ot_optimizer/Classes/Middleware/Frontend/OtPageResolver.php

@@ -58,9 +58,9 @@ class OtPageResolver extends \TYPO3\CMS\Frontend\Middleware\PageResolver
 
         // 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']
+        $requestedFromBE = (
+                preg_match("/.+\/typo3\/index.php\?route=.*(Viewpage)|(FrontendEditing).*/", $_SERVER['HTTP_REFERER']) ||
+                $request->getQueryParams()['frontend_editing'] === 'true'
             )
             && $GLOBALS['BE_USER'];
 

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

@@ -11,14 +11,8 @@ plugin.tx_ottemplating {
     }
     settings {
         opentalent {
-            website = https://opentalent.fr
             logoPath = EXT:ot_templating/Resources/Public/media/logo-opentalent.png
-            fileStorageUrl = https://api.opentalent.fr/app.php/_internal/secure/files/
-            dashboardUrl = https://admin.opentalent.fr/#/dashboard
-            loginPageUrl = https://admin.opentalent.fr/#/login
-            logoutUrl = .
         }
-
         organization {
             # >> Ces paramètres doivent être redéfinis dans le gabarit du site
             id = 0

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

@@ -76,12 +76,7 @@ plugin.tx_ottemplating {
         layoutRootPaths.0 = {$layoutRootPath}
     }
     settings {
-        opentalentWebsite = {$plugin.tx_ottemplating.settings.opentalent.website}
         opentalentLogoPath = {$plugin.tx_ottemplating.settings.opentalent.logoPath}
-        opentalentFileStorageUrl = {$plugin.tx_ottemplating.settings.opentalent.fileStorageUrl}
-        opentalentDashboardUrl = {$plugin.tx_ottemplating.settings.opentalent.dashboardUrl}
-        opentalentLoginPageUrl = {$plugin.tx_ottemplating.settings.opentalent.loginPageUrl}/{$plugin.tx_ottemplating.settings.organization.id}
-        opentalentLogoutUrl = {$plugin.tx_ottemplating.settings.opentalent.logoutUrl}
         structureId = {$plugin.tx_ottemplating.settings.organization.id}
         structureLogoId = {$plugin.tx_ottemplating.settings.organization.logoid}
         structureName = {$plugin.tx_ottemplating.settings.organization.name}
@@ -110,7 +105,6 @@ plugin.tx_ottemplating {
         staticDonors = {$plugin.tx_ottemplating.settings.donors.static}
         eventsLimit = {$plugin.tx_ottemplating.settings.events.limit}
         eventsPeriod = {$plugin.tx_ottemplating.settings.events.period}
-
     }
 }
 

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

@@ -50,7 +50,7 @@
     </ul>
 
     <div class="logo-ot">
-        <a href="{settings.opentalentWebsite}" target="_blank" title="Opentalent">
+        <a href="{ot:request.getOtEnvVar(argument: 'WEBSITE')}" target="_blank" title="Opentalent">
             <f:image src="EXT:ot_templating/Resources/Public/media/logo-opentalent.png" height="40" />
         </a>
     </div>

+ 2 - 2
ot_templating/Resources/Private/Partials/Classic/ShareBar.html

@@ -10,7 +10,7 @@
         'facebook-share-dialog',
         'width=626,height=436');
       return false;">
-    <i class="fab fa-facebook" style="color: #129af6"></i> Facebook
+    <i class="fab fa-facebook"></i> Facebook
   </a>
 
   <a href="#"
@@ -20,6 +20,6 @@
         'twitter-share-dialog',
         'width=626,height=436');
       return false;">
-    <i class="fab fa-twitter" style="color: #1da1f2"></i> Twitter
+    <i class="fab fa-twitter"></i> Twitter
   </a>
 </div>

+ 2 - 2
ot_templating/Resources/Private/Partials/Classic/UserToolbar.html

@@ -17,7 +17,7 @@
 
                 <ul class="dropdown-menu">
                     <li>
-                        <a href="{settings.opentalentDashboardUrl}" target="_blank">
+                        <a href="{ot:request.getOtEnvVar(argument: 'DASHBOARD_URL')}" target="_blank">
                             <f:translate key="member-area-of-my-structure"/>
                         </a>
                     </li>
@@ -75,7 +75,7 @@
 
                 </f:then>
                 <f:else>
-                    <a href="{settings.opentalentLoginPageUrl}" target="_blank">
+                    <a href="{ot:request.getOtEnvVar(argument: 'LOGIN_PAGE_URL')}" target="_blank">
                         <i class="fas fa-power-off"></i> <f:translate key="login"/>
                     </a>
                 </f:else>

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

@@ -131,7 +131,7 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="button gray" data-dismiss="modal">Fermer</button>
-                <a href="{settings.opentalentWebsite}" class="button opentalent-bg no-border" target="_blank">opentalent.fr</a>
+                <a href="{ot:request.getOtEnvVar(argument: 'WEBSITE')}" class="button opentalent-bg no-border" target="_blank">opentalent.fr</a>
             </div>
         </div>
     </div>

+ 29 - 9
ot_templating/Resources/Private/Partials/Modern/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"/>
 <v:variable.set value="{f:uri.image(src: 'EXT:ot_templating/Resources/Public/media/event-default-modern.jpg')}" name="defaultImage"/>
 
 <f:comment><!-- Should we display the section even if there is no event to show?--></f:comment>
@@ -80,17 +81,36 @@
                         </div>
                     </f:for>
 
-                    <f:if condition="{eventsPageUid} > 0">
-                        <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">
-                                <f:link.page pageUid="{eventsPageUid}" class="p-4 more-events">
-                                    <h2 class="text-white"> <i class="fa fa-plus fa-3x"></i> </h2>
-                                    <h3 class="text-white"> <f:translate key="see-all-events"/> </h3>
-                                </f:link.page>
-                            </div>
-                        </div>
+                    <f:if condition="{fromParents}">
+                        <f:then>
+                        </f:then>
+                        <f:else if="{fromChildren}">
+                            <f:if condition="{childrenEventsPageUid} > 0"><f:then>
+                                <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">
+                                        <f:link.page pageUid="{childrenEventsPageUid}" class="p-4 more-events">
+                                            <h2 class="text-white"> <i class="fa fa-plus fa-3x"></i> </h2>
+                                            <h3 class="text-white"> <f:translate key="see-all-events"/> </h3>
+                                        </f:link.page>
+                                    </div>
+                                </div>
+                            </f:then></f:if>
+                        </f:else>
+                        <f:else>
+                            <f:if condition="{eventsPageUid} > 0"><f:then>
+                                <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">
+                                        <f:link.page pageUid="{eventsPageUid}" class="p-4 more-events">
+                                            <h2 class="text-white"> <i class="fa fa-plus fa-3x"></i> </h2>
+                                            <h3 class="text-white"> <f:translate key="see-all-events"/> </h3>
+                                        </f:link.page>
+                                    </div>
+                                </div>
+                            </f:then></f:if>
+                        </f:else>
                     </f:if>
 
+
                 </f:if>
 
             </ot:events.getNext>

+ 2 - 2
ot_templating/Resources/Private/Partials/Modern/ShareBar.html

@@ -10,7 +10,7 @@
         'facebook-share-dialog',
         'width=626,height=436');
       return false;">
-    <i class="fa fa-facebook" style="color: #129af6"></i> Facebook
+    <i class="fa fa-facebook"></i> Facebook
   </a>
 
   <a href="#"
@@ -20,6 +20,6 @@
         'twitter-share-dialog',
         'width=626,height=436');
       return false;">
-    <i class="fa fa-twitter" style="color: #1da1f2"></i> Twitter
+    <i class="fa fa-twitter"></i> Twitter
   </a>
 </div>

+ 2 - 2
ot_templating/Resources/Private/Partials/Modern/UserToolbar.html

@@ -12,7 +12,7 @@
                 <span><f:translate key="welcome"/> <b>{feuser.username}</b>!</span>
             </li>
             <li>
-                <a href="{settings.opentalentDashboardUrl}">
+                <a href="{ot:request.getOtEnvVar(argument: 'DASHBOARD_URL')}">
                     <f:translate key="member-area-of-my-structure"/>
                 </a>
             </li>
@@ -36,7 +36,7 @@
                         </a>
                     </f:then>
                     <f:else>
-                        <a href="{settings.opentalentLoginPageUrl}"
+                        <a href="{ot:request.getOtEnvVar(argument: 'LOGIN_PAGE_URL')}"
                            target="_blank"
                            class="{f:if(condition: '{ot:loginFailed()}', then: 'trigger-on-load')}"
                         >