Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Fischer committed Apr 15, 2024
2 parents c007f89 + 2569155 commit a1f7704
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 9 deletions.
52 changes: 52 additions & 0 deletions Classes/Xclass/ContainerGridColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

use B13\Container\Backend\Grid\ContainerGridColumn as BaseContainerGridColumn;
use B13\Container\Domain\Model\Container;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ContainerGridColumn extends BaseContainerGridColumn
{
Expand All @@ -39,4 +41,54 @@ public function getCollapsed(): bool
{
return $this->collapsed;
}

public function getChildAllowedTypesCount(): int
{
$allowed = $this->definition['allowed'] ?? [];
$cType = explode(',', $allowed['CType'] ?? '');
$listType = explode(',', $allowed['list_type'] ?? '');

return count($cType)
// only add list type count if list is in cType minus 1 for the list cType itself
+ (in_array('list', $cType) ? count($listType) - 1 : 0);
}

public function getNewContentUrl(): string
{
$pageId = $this->context->getPageId();

$urlParameters = [
'edit' => [
'tt_content' => [
$pageId => 'new',
],
],
'defVals' => [
'tt_content' => [
'colPos' => $this->getColumnNumber(),
'sys_language_uid' => $this->container->getLanguage(),
'tx_container_parent' => $this->container->getUidOfLiveWorkspace(),
'uid_pid' => $this->newContentElementAtTopTarget,
],
],
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri(),
];
$routeName = 'record_edit';

$allowed = $this->definition['allowed'] ?? [];
if (!empty($allowed)) {
$cType = $allowed['CType'] ?? '';
if ($cType) {
$urlParameters['defVals']['tt_content']['CType'] = $cType;
}

$listType = $allowed['list_type'] ?? '';
if ($listType) {
$urlParameters['defVals']['tt_content']['list_type'] = $listType;
}
}

$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
}
}
57 changes: 57 additions & 0 deletions Classes/Xclass/ContainerGridColumnItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

namespace Evoweb\EwCollapsibleContainer\Xclass;

/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* 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.
*/

use B13\Container\Backend\Grid\ContainerGridColumnItem as BaseContainerGridColumnItem;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ContainerGridColumnItem extends BaseContainerGridColumnItem
{
public function getNewContentAfterUrl(): string
{
$urlParameters = [
'edit' => [
'tt_content' => [
-$this->record['uid'] => 'new',
],
],
'defVals' => [
'tt_content' => [
'colPos' => $this->column->getColumnNumber(),
'sys_language_uid' => $this->container->getLanguage(),
'tx_container_parent' => $this->container->getUidOfLiveWorkspace(),
'uid_pid' => -$this->record['uid'],
],
],
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri(),
];
$routeName = 'record_edit';

$allowed = $this->column->getDefinition()['allowed'] ?? [];
if (!empty($allowed)) {
$cType = $allowed['CType'] ?? '';
if ($cType) {
$urlParameters['defVals']['tt_content']['CType'] = $cType;
}

$listType = $allowed['list_type'] ?? '';
if ($listType) {
$urlParameters['defVals']['tt_content']['list_type'] = $listType;
}
}

$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
}
}
22 changes: 16 additions & 6 deletions Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,22 @@
<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}">
<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}
</button>
</typo3-backend-new-content-element-wizard-button>
<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}
</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}
</button>
</typo3-backend-new-content-element-wizard-button>
</f:else>
</f:if>
</div>
<div class="t3-page-ce-dropzone t3js-page-ce-dropzone-available"></div>
</div>
Expand Down
40 changes: 40 additions & 0 deletions Resources/Private/Partials/PageLayout/Record.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{f:if(condition: '{item.disabled} && {item.context.drawingConfiguration.showHidden} == 0', then: 'height: 0; position: absolute;') -> 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">
<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">
<f:render partial="PageLayout/RecordDefault/Preview" arguments="{_all}" />
</div>
</f:spaceless>
<f:render partial="PageLayout/Record/{item.record.CType}/Footer" arguments="{_all}" optional="1">
<f:render partial="PageLayout/RecordDefault/Footer" arguments="{_all}" />
</f:render>
<f:if condition="{item.inconsistentLanguage}">
<div class="t3-page-ce-footer">
<span class="badge badge-warning">{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.inconsistentLanguageWarning')}</span>
</div>
</f:if>
</div>
<f:if condition="{allowEditContent} && {item.column.contentEditable} && {column.context.allowNewContent} && {column.active}">
<div class="t3-page-ce-actions t3js-page-new-ce">
<f:if condition="{item.column.childAllowedTypesCount} == 1">
<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" />
</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" />
</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>
10 changes: 8 additions & 2 deletions Resources/Private/PartialsPre12/PageLayout/Grid/Column.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@
<f:if condition="{allowEditContent} && {column.contentEditable} && {column.allowNewContent}">
<div class="t3-page-ce t3js-page-ce" data-page="{column.context.pageId}" id="{column.uniqueId}">
<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-{column.columnNumber}-page-{column.context.pageId}-{column.uniqueId}">
<f:if condition="{column.context.drawingConfiguration.showNewContentWizard}">
<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}
</a>
</f:then>
<f:else if="{column.context.drawingConfiguration.showNewContentWizard}">
<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}
</button>
</typo3-backend-new-content-element-wizard-button>
</f:then>
</f:else>
<f:else>
<a href="{column.newContentUrl}" title="{newContentTitle}" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
Expand Down
41 changes: 41 additions & 0 deletions Resources/Private/PartialsPre12/PageLayout/Record.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<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 t3js-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">
<f:render partial="PageLayout/RecordDefault/Preview" arguments="{_all}" />
</div>
</f:spaceless>
<f:render partial="PageLayout/Record/{item.record.CType}/Footer" arguments="{_all}" optional="1">
<f:render partial="PageLayout/RecordDefault/Footer" arguments="{_all}" />
</f:render>
</div>
<f:if condition="{allowEditContent} && {item.column.contentEditable} && {item.column.allowNewContent} && {column.active}">
<div class="t3-page-ce-actions t3js-page-new-ce" id="colpos-{item.column.columnNumber}-page-{item.context.pageId}-{item.column.uniqueId}">
<f:if condition="{item.column.childAllowedTypesCount} == 1">
<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" />
</a>
</f:then>
<f:else>
<typo3-backend-new-content-element-wizard-button url="{item.newContentAfterUrl}" title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newContentElement')}">
<button type="button" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
<f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:content" />
</button>
</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>
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'author_email' => '[email protected]',
'author_company' => 'evoWeb',
'state' => 'stable',
'version' => '1.0.0',
'version' => '1.3.0',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-12.4.99',
Expand Down
5 changes: 5 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use B13\Container\Tca\ContainerConfiguration as BaseContainerConfiguration;
use B13\Container\Backend\Grid\ContainerGridColumn as BaseContainerGridColumn;
use B13\Container\Backend\Grid\ContainerGridColumnItem as BaseContainerGridColumnItem;
use B13\Container\Backend\Preview\ContainerPreviewRenderer as BaseContainerPreviewRenderer;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerConfiguration;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumnItem;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerPreviewRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

Expand All @@ -21,5 +23,8 @@
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseContainerPreviewRenderer::class] = [
'className' => ContainerPreviewRenderer::class
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseContainerGridColumnItem::class] = [
'className' => ContainerGridColumnItem::class
];
}
});

0 comments on commit a1f7704

Please sign in to comment.