From bdf08f058daa321777fad93e3dd3ce72896888a2 Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Sun, 14 Jul 2024 15:46:30 +0200 Subject: [PATCH 1/4] Add extension scanner ignore line --- Classes/Xclass/ContainerGridColumn.php | 9 ++++++++- Classes/Xclass/ContainerGridColumnItem.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Classes/Xclass/ContainerGridColumn.php b/Classes/Xclass/ContainerGridColumn.php index 882c939..f5a63cc 100644 --- a/Classes/Xclass/ContainerGridColumn.php +++ b/Classes/Xclass/ContainerGridColumn.php @@ -17,6 +17,7 @@ use B13\Container\Backend\Grid\ContainerGridColumn as BaseContainerGridColumn; use B13\Container\Domain\Model\Container; +use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\View\PageLayoutContext; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -84,7 +85,8 @@ public function getNewContentUrl(): string 'uid_pid' => $this->newContentElementAtTopTarget, ], ], - 'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri(), + // @extensionScannerIgnoreLine + 'returnUrl' => $this->getRequest()->getAttribute('normalizedParams')->getRequestUri(), ]; $routeName = 'record_edit'; @@ -126,4 +128,9 @@ public function getHiddenItemCount(): int ) ); } + + protected function getRequest(): ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } } diff --git a/Classes/Xclass/ContainerGridColumnItem.php b/Classes/Xclass/ContainerGridColumnItem.php index 3590ec4..b8f934a 100644 --- a/Classes/Xclass/ContainerGridColumnItem.php +++ b/Classes/Xclass/ContainerGridColumnItem.php @@ -16,6 +16,7 @@ namespace Evoweb\EwCollapsibleContainer\Xclass; use B13\Container\Backend\Grid\ContainerGridColumnItem as BaseContainerGridColumnItem; +use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -42,7 +43,8 @@ public function getNewContentAfterUrl(): string 'uid_pid' => -$this->record['uid'], ], ], - 'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri(), + // @extensionScannerIgnoreLine + 'returnUrl' => $this->getRequest()->getAttribute('normalizedParams')->getRequestUri(), ]; $routeName = 'record_edit'; @@ -68,4 +70,9 @@ public function isHidden(): bool { return ($this->record['hidden'] ?? 0) > 0; } + + protected function getRequest(): ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } } From f7f59324cc19d51973ce24e0c3f43add7a8d855b Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Fri, 9 Aug 2024 21:44:05 +0200 Subject: [PATCH 2/4] [TASK] Cleanup for TYPO3 13 --- Classes/Xclass/ContainerConfiguration.php | 17 +-- Classes/Xclass/ContainerGridColumn.php | 9 +- Classes/Xclass/ContainerGridColumnItem.php | 5 - Classes/Xclass/ContainerPreviewRenderer.php | 11 +- .../PartialsPre12/PageLayout/Grid/Column.html | 125 ------------------ .../PartialsPre12/PageLayout/Record.html | 43 ------ .../Templates/Container/GridPre12.html | 31 ----- composer.json | 6 +- ext_emconf.php | 4 +- 9 files changed, 20 insertions(+), 231 deletions(-) delete mode 100644 Resources/Private/PartialsPre12/PageLayout/Grid/Column.html delete mode 100644 Resources/Private/PartialsPre12/PageLayout/Record.html delete mode 100644 Resources/Private/Templates/Container/GridPre12.html diff --git a/Classes/Xclass/ContainerConfiguration.php b/Classes/Xclass/ContainerConfiguration.php index e7518b1..bd35412 100644 --- a/Classes/Xclass/ContainerConfiguration.php +++ b/Classes/Xclass/ContainerConfiguration.php @@ -16,16 +16,9 @@ namespace Evoweb\EwCollapsibleContainer\Xclass; use B13\Container\Tca\ContainerConfiguration as BaseContainerConfiguration; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Utility\GeneralUtility; class ContainerConfiguration extends BaseContainerConfiguration { - /** - * @var string - */ - protected $gridTemplate = 'EXT:ew_collapsible_container/Resources/Private/Templates/Container/Grid.html'; - public function __construct( string $cType, string $label, @@ -33,13 +26,7 @@ public function __construct( array $grid ) { parent::__construct($cType, $label, $description, $grid); - if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) { - $this->addGridPartialPath('EXT:ew_collapsible_container/Resources/Private/PartialsPre12/'); - $this->setGridTemplate( - 'EXT:ew_collapsible_container/Resources/Private/Templates/Container/GridPre12.html' - ); - } else { - $this->addGridPartialPath('EXT:ew_collapsible_container/Resources/Private/Partials/'); - } + $this->setGridTemplate('EXT:ew_collapsible_container/Resources/Private/Templates/Container/Grid.html'); + $this->addGridPartialPath('EXT:ew_collapsible_container/Resources/Private/Partials/'); } } diff --git a/Classes/Xclass/ContainerGridColumn.php b/Classes/Xclass/ContainerGridColumn.php index f5a63cc..34c91e7 100644 --- a/Classes/Xclass/ContainerGridColumn.php +++ b/Classes/Xclass/ContainerGridColumn.php @@ -47,6 +47,11 @@ public function getCollapsed(): bool return $this->collapsed; } + public function setCollapsed(bool $collapsed): void + { + $this->collapsed = $collapsed; + } + public function getChildAllowedTypesCount(): int { if (!($this->definition['allowDirectNewLink'] ?? false)) { @@ -111,7 +116,7 @@ public function getNewContentUrl(): string public function hasShowMinItemsWarning(): bool { return count($this->items) > 0 - && (count($this->items) - $this->getHiddenItemCount()) < $this->minItems; + && (count($this->items) - $this->getHiddenItemCount()) < $this->getMinItems(); } public function getMinItems(): int @@ -124,7 +129,7 @@ public function getHiddenItemCount(): int return count( array_filter( $this->items, - fn (ContainerGridColumnItem $item) => $item->isHidden() + fn (ContainerGridColumnItem $item) => ($item->getRecord()['hidden'] ?? 0) > 0 ) ); } diff --git a/Classes/Xclass/ContainerGridColumnItem.php b/Classes/Xclass/ContainerGridColumnItem.php index b8f934a..8e42298 100644 --- a/Classes/Xclass/ContainerGridColumnItem.php +++ b/Classes/Xclass/ContainerGridColumnItem.php @@ -66,11 +66,6 @@ public function getNewContentAfterUrl(): string return (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters); } - public function isHidden(): bool - { - return ($this->record['hidden'] ?? 0) > 0; - } - protected function getRequest(): ServerRequestInterface { return $GLOBALS['TYPO3_REQUEST']; diff --git a/Classes/Xclass/ContainerPreviewRenderer.php b/Classes/Xclass/ContainerPreviewRenderer.php index 9f72d39..65ce5a8 100644 --- a/Classes/Xclass/ContainerPreviewRenderer.php +++ b/Classes/Xclass/ContainerPreviewRenderer.php @@ -19,6 +19,7 @@ use B13\Container\Backend\Grid\ContainerGridColumnItem; use B13\Container\Backend\Preview\ContainerPreviewRenderer as BaseContainerPreviewRenderer; use B13\Container\Domain\Factory\Exception; +use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn as BaseContainerGridColumn; use TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendLayout\Grid\Grid; @@ -54,7 +55,6 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string $container, $col['colPos'] ); - $collapsed = $this->getColumnCollapsedState((int)$record['uid'], (int)$col['colPos'], $col); $columnObject = GeneralUtility::makeInstance( ContainerGridColumn::class, $context, @@ -62,9 +62,10 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string $container, $newContentElementAtTopTarget, $allowNewContentElements, - $collapsed, + false, $col['minitems'] ?? 0 ); + $this->setColumnCollapsedState((int)$record['uid'], $columnObject, $col); $rowObject->addColumn($columnObject); if (isset($col['colPos'])) { $records = $container->getChildrenByColPos($col['colPos']); @@ -117,14 +118,14 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string return $content . $rendered; } - protected function getColumnCollapsedState(int $recordUid, int $colPos, array $col): bool + protected function setColumnCollapsedState(int $recordUid, BaseContainerGridColumn $columnObject, array $col): void { - $collapseId = $recordUid . ContainerGridColumn::CONTAINER_COL_POS_DELIMITER_V12 . $colPos; + $collapseId = $recordUid . $columnObject->getColumnNumber(); if (isset($this->getBackendUser()->uc['moduleData']['list']['containerExpanded'][$collapseId])) { $collapsed = $this->getBackendUser()->uc['moduleData']['list']['containerExpanded'][$collapseId] > 0; } else { $collapsed = (bool)($col['collapsed'] ?? false); } - return $collapsed; + $columnObject->setCollapsed($collapsed); } } diff --git a/Resources/Private/PartialsPre12/PageLayout/Grid/Column.html b/Resources/Private/PartialsPre12/PageLayout/Grid/Column.html deleted file mode 100644 index 36bf098..0000000 --- a/Resources/Private/PartialsPre12/PageLayout/Grid/Column.html +++ /dev/null @@ -1,125 +0,0 @@ - -remove class t3-grid-cell (for tests) -change data-colpos attr - -
- - -
- - - - - - - - - - - -
- {column.title} - - - - - - - - - - -
- - {column.title} ({column.titleUnassigned}) - - - {column.titleInaccessible} - - - {column.titleInaccessible} - -
-
- use column.allowNewContent instead of pageContext - -
-
- - - - - {newContentTitleShort} - - - - - - - - - - - {newContentTitleShort} - - - -
-
-
-
- -
- - {f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')} -
-
- -
-
Empty Colpos
-
-
-
-
- This column has no "colPos". This is only for display Purposes. -
-
-
-
-
-
- - change data-colpos attr -
- - - - - -
-
- - diff --git a/Resources/Private/PartialsPre12/PageLayout/Record.html b/Resources/Private/PartialsPre12/PageLayout/Record.html deleted file mode 100644 index 57877dc..0000000 --- a/Resources/Private/PartialsPre12/PageLayout/Record.html +++ /dev/null @@ -1,43 +0,0 @@ - -{f:if(condition: '{item.disabled} && {item.context.drawingConfiguration.showHidden} == 0', then: 'display: none;') -> f:variable(name: 'style')} -
-
- - - - -
-
- -
-
-
- - - -
- -
- - - - - - - - - - - - - -
-
-
-
- diff --git a/Resources/Private/Templates/Container/GridPre12.html b/Resources/Private/Templates/Container/GridPre12.html deleted file mode 100644 index 7f9524f..0000000 --- a/Resources/Private/Templates/Container/GridPre12.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - View\ContainerLayoutView - - - - - - - - -
- -
-
- - - Backend\Preview\ContainerLayoutView (Fluid based page module) - - - - diff --git a/composer.json b/composer.json index 6b3dae4..f066c3f 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,11 @@ "GPL-2.0-or-later" ], "require": { - "typo3/cms-backend": "^11.5 || ^12.4 || ^13.0 || 13.0.x-dev || dev-main", - "typo3/cms-core": "^11.5 || ^12.4 || ^13.0 || 13.0.x-dev || dev-main" + "typo3/cms-backend": "^13.0 || 13.0.x-dev || dev-main", + "typo3/cms-core": "^13.0 || 13.0.x-dev || dev-main" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.57.1" + "friendsofphp/php-cs-fixer": "^3.62.0" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/ext_emconf.php b/ext_emconf.php index e6efb8d..c2b8d58 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,10 +8,10 @@ 'author_email' => 'ew-collapsible-container@evoweb.de', 'author_company' => 'evoWeb', 'state' => 'stable', - 'version' => '1.4.4', + 'version' => '2.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '11.5.0-13.4.99', + 'typo3' => '13.4.0-13.4.99', ], ], ]; From 6f67d178cebf4d837b60a87931fe766da8bce7fc Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Sat, 10 Aug 2024 20:59:17 +0200 Subject: [PATCH 3/4] [TASK] Get templates in line with EXT:container and EXT:backend --- .../Partials/PageLayout/Grid/Column.html | 18 +-- .../PageLayout/Grid/ColumnHeader.html | 45 ++++--- .../Private/Partials/PageLayout/Record.html | 16 ++- .../Private/Templates/Container/Grid.html | 20 --- Resources/Public/JavaScript/ContainerPre12.js | 125 ------------------ 5 files changed, 42 insertions(+), 182 deletions(-) delete mode 100644 Resources/Public/JavaScript/ContainerPre12.js diff --git a/Resources/Private/Partials/PageLayout/Grid/Column.html b/Resources/Private/Partials/PageLayout/Grid/Column.html index 569479c..8ecd10a 100644 --- a/Resources/Private/Partials/PageLayout/Grid/Column.html +++ b/Resources/Private/Partials/PageLayout/Grid/Column.html @@ -1,21 +1,16 @@ - - Styling requires the colpos to be set to the string 'unused'. To preserve type safety in the - controller, the string is only used in the template by setting the below "colpos" variable. - - - + + t3-gridCell-height{column.rowSpan}" role="group" aria-labelledby="{columnIdentifier}"> -
@@ -25,3 +20,4 @@ {column.afterSectionMarkup} + diff --git a/Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html b/Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html index 42be48c..59f7160 100644 --- a/Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html +++ b/Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html @@ -1,7 +1,11 @@ + +
-
+
- - + + + +
- {column.title} + {column.title} - - - - - - - - + + + + + + + + - + - {column.titleUnassigned} + {column.titleUnassigned} - {column.titleInaccessible} + {column.titleInaccessible}
{column.beforeSectionMarkup} -
-
+
+
- {newContentTitleShort} + @@ -77,3 +83,4 @@ {f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
+ diff --git a/Resources/Private/Partials/PageLayout/Record.html b/Resources/Private/Partials/PageLayout/Record.html index f7dc354..1914081 100644 --- a/Resources/Private/Partials/PageLayout/Record.html +++ b/Resources/Private/Partials/PageLayout/Record.html @@ -1,14 +1,15 @@ -{f:if(condition: '{item.disabled} && {item.context.drawingConfiguration.showHidden} == 0', then: 'height: 0; position: absolute;') -> f:variable(name: 'style')} + +{f:if(condition: '{item.disabled} && {item.context.drawingConfiguration.showHidden} == 0', then: 'display: none;') -> f:variable(name: 'style')}
-
+
-
- -
+
@@ -26,13 +27,13 @@ - + - + @@ -40,3 +41,4 @@
+ diff --git a/Resources/Private/Templates/Container/Grid.html b/Resources/Private/Templates/Container/Grid.html index f28b344..89ae4e3 100644 --- a/Resources/Private/Templates/Container/Grid.html +++ b/Resources/Private/Templates/Container/Grid.html @@ -1,31 +1,11 @@ - - - - View\ContainerLayoutView - - - - - - - - -
- -
-
- - Backend\Preview\ContainerLayoutView (Fluid based page module) - diff --git a/Resources/Public/JavaScript/ContainerPre12.js b/Resources/Public/JavaScript/ContainerPre12.js deleted file mode 100644 index 5b41aa6..0000000 --- a/Resources/Public/JavaScript/ContainerPre12.js +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ -class ContainerToggle { - containerColumnToggle = '.t3js-toggle-container-column'; - - columnExpand = '.t3js-expand-column'; - - persistentStorage = null; - - storageKey = 'moduleData.list.containerExpanded'; - - constructor(PersistentStorage) { - this.persistentStorage = PersistentStorage; - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', () => { - this.initialized(); - }); - } else { - this.initialized(); - } - } - - initialized() { - this.initializeContainerToggle(); - this.initializeExpandColumn(); - } - - /** - * initialize the toggle icons to open listings of nested grid container structure in the list module - */ - initializeContainerToggle() { - const containers = Array.from(document.querySelectorAll(this.containerColumnToggle)); - containers.forEach(container=> { - container.addEventListener('click', event => this.toggleClicked(event)); - }); - } - - initializeExpandColumn() { - const columnExpanders = Array.from(document.querySelectorAll(this.columnExpand)); - columnExpanders.forEach(columnExpander=> { - columnExpander.addEventListener('click', event => this.expandClicked(event)); - }); - } - - toggleClicked(event) { - event.preventDefault(); - - let column = event.currentTarget, - containerCell = column.closest('td'), - colPos = parseInt(containerCell.dataset['colpos']), - isExpanded = column.dataset['collapseState'] === 'expanded', - storedModuleDataList = this.getCurrentModuleDataList(colPos, isExpanded); - - // Store collapse state in UC - this.setStoredModuleDataList(storedModuleDataList).then(() => { - if (isExpanded) { - containerCell.classList.add('collapsed'); - } else { - containerCell.classList.remove('collapsed'); - } - }); - } - - expandClicked(event) { - event.preventDefault(); - - let expander = event.currentTarget, - containerCell = expander.closest('td'), - colPos = parseInt(containerCell.dataset['colpos']), - isExpanded = false, - storedModuleDataList = this.getCurrentModuleDataList(colPos, isExpanded); - - // Store collapse state in UC - this.setStoredModuleDataList(storedModuleDataList).then(() => { - containerCell.classList.remove('collapsed'); - }); - } - - /** - * @param {number} colPos - * @param {boolean} isExpanded - * - * @returns {object} - */ - getCurrentModuleDataList(colPos, isExpanded) { - let storedModuleDataList = {}; - - if (this.persistentStorage.isset(this.storageKey)) { - storedModuleDataList = this.persistentStorage.get(this.storageKey); - } - - let collapseConfig = {}; - collapseConfig[colPos] = isExpanded ? '1' : '0'; - - return Object.assign(storedModuleDataList, collapseConfig); - } - - /** - * @param {object} moduleData - * - * @returns {Promise} - */ - setStoredModuleDataList(moduleData) { - return this.persistentStorage.set(this.storageKey, moduleData); - } -} - -define( - [ - 'TYPO3/CMS/Backend/Storage/Persistent' - ], - function(PersistentStorage) { - return new ContainerToggle(PersistentStorage); - } -); From 69f8610d8d225ebe9e3c3e1daedeef51fab76fa3 Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Sat, 10 Aug 2024 21:41:49 +0200 Subject: [PATCH 4/4] [TASK] Fix collapse due to changed collapseId --- Classes/Xclass/ContainerPreviewRenderer.php | 2 +- .../Partials/PageLayout/Grid/Column.html | 2 +- Resources/Public/JavaScript/container.js | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Classes/Xclass/ContainerPreviewRenderer.php b/Classes/Xclass/ContainerPreviewRenderer.php index 65ce5a8..27e3d9d 100644 --- a/Classes/Xclass/ContainerPreviewRenderer.php +++ b/Classes/Xclass/ContainerPreviewRenderer.php @@ -120,7 +120,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string protected function setColumnCollapsedState(int $recordUid, BaseContainerGridColumn $columnObject, array $col): void { - $collapseId = $recordUid . $columnObject->getColumnNumber(); + $collapseId = $recordUid . ContainerGridColumn::CONTAINER_COL_POS_DELIMITER . $columnObject->getColumnNumber(); if (isset($this->getBackendUser()->uc['moduleData']['list']['containerExpanded'][$collapseId])) { $collapsed = $this->getBackendUser()->uc['moduleData']['list']['containerExpanded'][$collapseId] > 0; } else { diff --git a/Resources/Private/Partials/PageLayout/Grid/Column.html b/Resources/Private/Partials/PageLayout/Grid/Column.html index 8ecd10a..582ca77 100644 --- a/Resources/Private/Partials/PageLayout/Grid/Column.html +++ b/Resources/Private/Partials/PageLayout/Grid/Column.html @@ -1,6 +1,6 @@