Olivier Massot 3 سال پیش
والد
کامیت
dbfc909cd3

+ 15 - 9
ot_templating/Classes/ViewHelpers/Members/GetAllViewHelper.php

@@ -89,18 +89,24 @@ class GetAllViewHelper extends OtAbstractViewHelper {
 
         // Sort by instrument (conductor first), then alphabetically by name
         usort($members,
-            function($a, $b) {
-                if ($a->getInstrument() == 'CONDUCTOR') {
+            static function($a, $b) {
+                if ($a->getInstrument() === 'CONDUCTOR') {
                     return -1;
-                } else if ($b->getInstrument() == 'CONDUCTOR') {
+                }
+
+                if ($b->getInstrument() === 'CONDUCTOR') {
                     return 1;
-                } else if ($a->getInstrument() != $b->getInstrument()) {
+                }
+
+                if ($a->getInstrument() !== $b->getInstrument()) {
                     return strcmp($a->getInstrument(), $b->getInstrument());
-                } else if ($a->getName() != $b->getName()) {
+                }
+
+                if ($a->getName() !== $b->getName()) {
                     return strcmp($a->getName(), $b->getName());
-                } else {
-                    return 0;
                 }
+
+                return 0;
             }
         );
 
@@ -113,13 +119,13 @@ class GetAllViewHelper extends OtAbstractViewHelper {
             foreach ($members as $member) {
                 // If that Instrument exist in stack1: put it in this one
                 if (array_key_exists($member->getInstrument(), $stack1)) {
-                    array_push($stack1[$member->getInstrument()], $member);
+                    $stack1[$member->getInstrument()][] = $member;
                 } else {
                     // Create the new array if needed in stack2, then put the member in it
                     if (!array_key_exists($member->getInstrument(), $stack2)) {
                         $stack2[$member->getInstrument()] = [];
                     }
-                    array_push($stack2[$member->getInstrument()], $member);
+                    $stack2[$member->getInstrument()][] = $member;
                 }
             }
 

+ 77 - 0
ot_templating/Classes/ViewHelpers/Page/GetFirstWithTemplateViewHelper.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace Opentalent\OtTemplating\ViewHelpers;
+
+
+use Closure;
+use Opentalent\OtCore\Website\OtPageRepository;
+use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+use Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
+
+/**
+ * Returns the uid of the first page with the given template in the current website, or null if none
+ *
+ *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
+ *
+ *     {ot:page.getFirstWithTemplate(template: 'foo')}
+ *
+ * @package Opentalent\OtTemplating\ViewHelpers
+ */
+class FirstWithTemplateViewHelper extends OtAbstractViewHelper
+{
+
+    /**
+     * -- This method is expected by Fluid --
+     * Declares the viewhelper's parameters
+     */
+    public function initializeArguments()
+    {
+        $this->registerArgument(
+            'template',
+            'string',
+            "The template's name",
+            true
+        );
+    }
+
+    /**
+     * -- This method is expected by Fluid --
+     * Renders the content as html
+     *
+     * @param array $arguments
+     * @param Closure $renderChildrenClosure
+     * @param RenderingContextInterface $renderingContext
+     * @return int|null
+     */
+    public static function renderStatic(
+        array $arguments,
+        Closure $renderChildrenClosure,
+        RenderingContextInterface $renderingContext
+    ) {
+        $rootId = GetIdViewHelper::renderStatic(
+            $arguments,
+            $renderChildrenClosure,
+            $renderingContext
+        );
+
+        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
+
+        $subpages = $pageRepository->getAllSubpagesForPage($rootId);
+
+        $templateName = 'OpenTalent.OtTemplating->' . $arguments['template'];
+
+        foreach ($subpages as $page) {
+            if ($page['tx_fed_page_controller_action'] === $templateName
+                & $page['deleted'] === 0
+                & $page['hidden'] === 0
+            ) {
+                return $page['uid'];
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -2,7 +2,7 @@
 {namespace ot=Opentalent\OtTemplating\ViewHelpers}
 
 <f:comment><!-- Special layout for the Members page --></f:comment>
-<f:layout name="Structures" />
+<f:layout name="StructuresDetails" />
 
 <v:asset.script name="classic-iframe-resizer"
                 path="EXT:ot_templating/Resources/Public/assets/Classic/script/iframeResizer.min.js"

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

@@ -24,7 +24,7 @@
                             <ul class="text-left text-md-right footer-menu">
 
                                 <li class="list-inline-item brand-free">
-                                    <a href="#"
+                                    <a href="https://opentalent.fr/"
                                        title="Opentalent"
                                        class="reseau-opentalent"
                                        data-toggle="modal"