Skip to content

Commit

Permalink
Merge tag '2.0.0'
Browse files Browse the repository at this point in the history
Release improved compatibility with TYPO3 13.x
  • Loading branch information
garbast committed Aug 11, 2024
2 parents 91e84cc + fb6a913 commit aa83ad3
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 418 deletions.
17 changes: 2 additions & 15 deletions Classes/Xclass/ContainerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,17 @@
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,
string $description,
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/');
}
}
18 changes: 15 additions & 3 deletions Classes/Xclass/ContainerGridColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,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)) {
Expand Down Expand Up @@ -84,7 +90,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';

Expand All @@ -109,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
Expand All @@ -122,8 +129,13 @@ public function getHiddenItemCount(): int
return count(
array_filter(
$this->items,
fn (ContainerGridColumnItem $item) => $item->isHidden()
fn (ContainerGridColumnItem $item) => ($item->getRecord()['hidden'] ?? 0) > 0
)
);
}

protected function getRequest(): ServerRequestInterface
{
return $GLOBALS['TYPO3_REQUEST'];
}
}
8 changes: 5 additions & 3 deletions Classes/Xclass/ContainerGridColumnItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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';

Expand All @@ -64,8 +66,8 @@ public function getNewContentAfterUrl(): string
return (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
}

public function isHidden(): bool
protected function getRequest(): ServerRequestInterface
{
return ($this->record['hidden'] ?? 0) > 0;
return $GLOBALS['TYPO3_REQUEST'];
}
}
11 changes: 6 additions & 5 deletions Classes/Xclass/ContainerPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,17 +55,17 @@ 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,
$col,
$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']);
Expand Down Expand Up @@ -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 . 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 {
$collapsed = (bool)($col['collapsed'] ?? false);
}
return $collapsed;
$columnObject->setCollapsed($collapsed);
}
}
18 changes: 7 additions & 11 deletions Resources/Private/Partials/PageLayout/Grid/Column.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<f:comment>
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.
</f:comment>
<f:variable name="colpos" value="{f:if(condition: column.unused, then: 'unused', else: column.columnNumber)}"/>

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<td valign="top" colspan="{column.colSpan}" rowspan="{column.rowSpan}"
data-colpos="{column.dataColPos}" data-language-uid="{column.context.siteLanguage.languageId}"
class="t3js-page-lang-column-{column.context.siteLanguage.languageId} t3js-page-column t3-grid-cell t3-page-column t3-page-column-{colpos}
{f:if(condition: column.unassigned, then: 't3-grid-cell-unassigned')}
data-colpos="{column.columnNumber}" data-tx-container-parent="{column.containerUid}" data-language-uid="{column.context.siteLanguage.languageId}"
class="t3js-page-lang-column-{column.context.siteLanguage.languageId} t3js-page-column t3-grid-cell t3-page-column t3-page-column-{column.columnNumber}
{f:if(condition: column.active, else: 't3-grid-cell-unassigned')}
{f:if(condition: '!{column.active} && !{column.unused}', then: 't3-grid-cell-restricted')}
{f:if(condition: '!{column.active} && {hideRestrictedColumns} && !{column.unused}', then: 't3-grid-cell-hidden')}
{f:if(condition: column.collapsed, then: 'collapsed')}
t3-gridCell-width{column.colSpan}
t3-gridCell-height{column.rowSpan}">
t3-gridCell-height{column.rowSpan}" role="group" aria-labelledby="{columnIdentifier}">
<f:render partial="PageLayout/Grid/ColumnHeader" arguments="{_all}" />
<f:if condition="{column.active} || {column.unused}">
<div data-colpos="{column.dataColPos}" data-language-uid="{column.context.siteLanguage.languageId}"
<div data-colpos="{column.containerUid}-{column.columnNumber}" data-language-uid="{column.context.siteLanguage.languageId}"
class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-{column.context.siteLanguage.languageId} t3-page-ce-wrapper
{f:if(condition: column.items, else: 't3-page-ce-empty')}">
<f:for each="{column.items}" as="item">
Expand All @@ -25,3 +20,4 @@
</f:if>
<f:format.raw>{column.afterSectionMarkup}</f:format.raw>
</td>
</html>
45 changes: 26 additions & 19 deletions Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:variable name="columnIdentifier" value="columnIdentifier_column-{column.columnNumber}"/>
<div class="t3-page-column-header">
<f:if condition="{column.active}">
<f:then>
<div class="btn-group t3-page-column-header-icons">
<div class="t3-page-column-header-icons">
<f:if condition="{collapsable}">
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
Expand All @@ -18,49 +22,51 @@
<core:icon identifier="actions-view-list-collapse" />
</a>
</f:if>
<f:if condition="{allowEditContent} && {column.editUrl}">
<a href="{column.editUrl}" title="{column.editLinkTitle}" class="btn btn-sm btn-default btn-borderless"><core:icon identifier="actions-document-open" /></a>
<f:if condition="{allowEditContent} && {column.contentEditable} && {column.allowNewContent}">
<a href="{column.editUrl}" title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:editColumn')}">
<core:icon identifier="actions-document-open" />
</a>
</f:if>
</div>
{column.title}
<span id="{columnIdentifier}">{column.title}</span>
<f:if condition="{column.showMinItemsWarning}"><span class="fw-bold link-danger">
<f:if condition="{column.hiddenItemCount}">
<f:then>
<f:translate id="LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:minimum-item-count-not-reached-with-hidden" arguments="{1: column.minitems, 2: column.hiddenItemCount}"/>
</f:then>
<f:else>
<f:translate id="LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:minimum-item-count-not-reached" arguments="{1: column.minitems}"/>
</f:else>
</f:if>
<f:if condition="{column.hiddenItemCount}">
<f:then>
<f:translate id="LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:minimum-item-count-not-reached-with-hidden" arguments="{1: column.minitems, 2: column.hiddenItemCount}"/>
</f:then>
<f:else>
<f:translate id="LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:minimum-item-count-not-reached" arguments="{1: column.minitems}"/>
</f:else>
</f:if>
</span></f:if>
</f:then>
<f:else if="{column.unused}">
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:unusedColPos"/>
<span id="{columnIdentifier}"><f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:unusedColPos"/></span>
</f:else>
<f:else if="{column.unassigned}">
{column.titleUnassigned}
<span id="{columnIdentifier}">{column.titleUnassigned}</span>
</f:else>
<f:else>
{column.titleInaccessible}
<span id="{columnIdentifier}">{column.titleInaccessible}</span>
</f:else>
</f:if>
</div>
<f:format.raw>{column.beforeSectionMarkup}</f:format.raw>
<f:if condition="{allowEditContent} && {column.contentEditable} && {column.allowNewContent} && {column.active}">
<div class="t3-page-ce t3js-page-ce" data-page="{column.context.pageId}" id="{column.uniqueId}">
<div class="t3-page-ce-actions t3js-page-new-ce" id="colpos-{column.columnNumber}-page-{column.context.pageId}-{column.uniqueId}">
<div class="t3-page-ce t3js-page-ce" data-page="{column.context.pageId}">
<div class="t3-page-ce-actions t3js-page-new-ce">
<f:if condition="{column.childAllowedTypesCount} == 1">
<f:then>
<a href="{column.newContentUrl}" title="{newContentTitle}" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
{newContentTitleShort}
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:createNewContent" />
</a>
</f:then>
<f:else>
<typo3-backend-new-content-element-wizard-button url="{column.newContentUrl}" title="{newContentTitle}">
<button type="button" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
{newContentTitleShort}
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:createNewContent" />
</button>
</typo3-backend-new-content-element-wizard-button>
</f:else>
Expand All @@ -77,3 +83,4 @@
{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
</div>
</f:if>
</html>
16 changes: 9 additions & 7 deletions Resources/Private/Partials/PageLayout/Record.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{f:if(condition: '{item.disabled} && {item.context.drawingConfiguration.showHidden} == 0', then: 'height: 0; position: absolute;') -> f:variable(name: 'style')}
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true">
{f:if(condition: '{item.disabled} && {item.context.drawingConfiguration.showHidden} == 0', then: 'display: none;') -> f:variable(name: 'style')}
<div class="t3-page-ce {item.wrapperClassName} t3js-page-ce t3js-page-ce-sortable" id="element-tt_content-{item.record.uid}" data-table="tt_content" data-uid="{item.record.uid}" data-language-uid="{item.record.sys_language_uid}" style="{style}">
<div class="t3-page-ce-element t3-page-ce-dragitem">
<div class="t3-page-ce-element t3-page-ce-dragitem" id="{item.uniqueId}">
<f:render partial="PageLayout/Record/{item.record.CType}/Header" arguments="{_all}" optional="1">
<f:render partial="PageLayout/RecordDefault/Header" arguments="{_all}" />
</f:render>
<f:spaceless>
<div class="t3-page-ce-body">
<div class="t3-page-ce-body-inner">
<f:render partial="PageLayout/RecordDefault/Preview" arguments="{_all}" />
</div>
<f:render partial="PageLayout/RecordDefault/Preview" arguments="{_all}" />
</div>
</f:spaceless>
<f:render partial="PageLayout/Record/{item.record.CType}/Footer" arguments="{_all}" optional="1">
Expand All @@ -26,17 +27,18 @@
<f:then>
<a href="{item.newContentAfterUrl}" title="{newContentTitle}" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:content" />
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:createNewContent" />
</a>
</f:then>
<f:else>
<typo3-backend-new-content-element-wizard-button class="btn btn-default btn-sm" url="{item.newContentAfterUrl}" subject="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newContentElement')}">
<core:icon identifier="actions-plus" />
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:content" />
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:createNewContent" />
</typo3-backend-new-content-element-wizard-button>
</f:else>
</f:if>
</div>
</f:if>
<div class="t3-page-ce-dropzone t3js-page-ce-dropzone-available"></div>
</div>
</html>
Loading

0 comments on commit aa83ad3

Please sign in to comment.