Skip to content

Commit

Permalink
Merge pull request #307 from t3solution/5.2.9
Browse files Browse the repository at this point in the history
New release v5.2.9
  • Loading branch information
t3solution authored Apr 5, 2023
2 parents 3b3c1e4 + b4dbb87 commit ea5975c
Show file tree
Hide file tree
Showing 112 changed files with 2,038 additions and 2,033 deletions.
90 changes: 32 additions & 58 deletions Classes/Backend/Preview/T3sbPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;

/*
Expand All @@ -31,25 +30,25 @@
class T3sbPreviewRenderer extends StandardContentPreviewRenderer
{

/**
* @var Registry
*/
protected $tcaRegistry;
/**
* @var Registry
*/
protected $tcaRegistry;

/**
* @var ContainerFactory
*/
protected $containerFactory;
/**
* @var ContainerFactory
*/
protected $containerFactory;

/**
* @var ContainerColumnConfigurationService
*/
protected $containerColumnConfigurationService;
/**
* @var ContainerColumnConfigurationService
*/
protected $containerColumnConfigurationService;

/**
* @var ContainerService
*/
protected $containerService;
/**
* @var ContainerService
*/
protected $containerService;


public function __construct(
Expand Down Expand Up @@ -117,17 +116,13 @@ public function renderPageModulePreviewHeader(GridColumnItem $item): string

public function renderPageModulePreviewContent(GridColumnItem $item): string
{
$typo3Version = new Typo3Version();
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
if ($typo3Version->getMajorVersion() === 11) {
$pageRenderer->loadRequireJsModule(
'TYPO3/CMS/T3sbootstrap/Bootstrap',
'function() { console.log("Loaded bootstrap.js by t3sbootstrap!"); }'
);
$pageRenderer->addCssFile('EXT:t3sbootstrap/Resources/Public/Backend/bestyles-v11.css');
} else {
$pageRenderer->addCssFile('EXT:t3sbootstrap/Resources/Public/Backend/bestyles-v10.css');
}
$pageRenderer->loadRequireJsModule(
'TYPO3/CMS/T3sbootstrap/Bootstrap',
'function() { console.log("Loaded bootstrap.js by t3sbootstrap!"); }'
);
$pageRenderer->addCssFile('EXT:t3sbootstrap/Resources/Public/Backend/bestyles.css');

$content = parent::renderPageModulePreviewContent($item);
$context = $item->getContext();
$record = $item->getRecord();
Expand Down Expand Up @@ -241,7 +236,9 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
if (!empty($flexconf['card_wrapper']) && $record['CType'] == 'card_wrapper') {
$out .= '<br />- Wrapper: Card '.$flexconf['card_wrapper'];
if ( !empty($flexconf['visibleCards']) ) {
$out .= '<br />- Visible Cards: '.$flexconf['visibleCards'];
if ($flexconf['card_wrapper'] !== 'flipper' && $flexconf['card_wrapper'] !== 'columns') {
$out .= '<br />- Visible Cards: '.$flexconf['visibleCards'];
}
}
if ( !empty($flexconf['interval']) ) {
$out .= '<br />- Interval: '.$flexconf['interval'];
Expand Down Expand Up @@ -355,11 +352,11 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$rowObject = GeneralUtility::makeInstance(GridRow::class, $context);
foreach ($cols as $col) {
$newContentElementAtTopTarget = $this->containerService->getNewContentElementAtTopTargetInColumn($container, $col['colPos']);
if ($this->containerColumnConfigurationService->isMaxitemsReached($container, $col['colPos'])) {
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $newContentElementAtTopTarget, false);
} else {
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $newContentElementAtTopTarget);
}
if ($this->containerColumnConfigurationService->isMaxitemsReached($container, $col['colPos'])) {
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $newContentElementAtTopTarget, false);
} else {
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $newContentElementAtTopTarget);
}
$rowObject->addColumn($columnObject);
if (!empty($col['colPos'])) {
$records = $container->getChildrenByColPos($col['colPos']);
Expand All @@ -383,7 +380,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$view->assign('newContentTitleShort', parent::getLanguageService()->getLL('content'));
$view->assign('allowEditContent', parent::getBackendUser()->check('tables_modify', 'tt_content'));
$view->assign('containerGrid', $grid);
$view->assign('defaultRecordDirectory', $this->hasDefaultDirectory() ? 'RecordDefault' : 'Record');
$view->assign('defaultRecordDirectory', 'Record');

$rendered = $view->render();

Expand All @@ -394,15 +391,13 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
}

$extconf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');
$typo3Version = new Typo3Version();
$show = $typo3Version->getMajorVersion() == 10 ? 'in' : 'show';

if ($extconf['previewClosedCollapsible']) {
$newContent = '<p style="margin-top:8px;margin-left:5px"><a data-toggle="collapse" href="#collapseContainer-'.$record['uid'].'" role="button" aria-expanded="false" aria-controls="collapseContainer-'.$record['uid'].'"><span class="icon icon-size-small icon-state-default"><span class="icon-markup"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g class="icon-color" style="color:red"><path d="M7.593 11.43L3.565 5.79A.5.5 0 0 1 3.972 5h8.057a.5.5 0 0 1 .407.791l-4.028 5.64a.5.5 0 0 1-.815-.001z"/></g></svg></span></span></a></p>
<div class="collapse" id="collapseContainer-'.$record['uid'].'"><div class="card card-body p-3">'.$rendered.'</div></div>';
} else {
$newContent = '<p style="margin-top:8px;margin-left:5px"><a data-toggle="collapse" href="#collapseContainer-'.$record['uid'].'" role="button" aria-expanded="true" aria-controls="collapseContainer-'.$record['uid'].'"><span class="icon icon-size-small icon-state-default"><span class="icon-markup"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g class="icon-color" style="color:red"><path d="M7.593 11.43L3.565 5.79A.5.5 0 0 1 3.972 5h8.057a.5.5 0 0 1 .407.791l-4.028 5.64a.5.5 0 0 1-.815-.001z"/></g></svg></span></span></a></p>
<div class="collapse '.$show.'" id="collapseContainer-'.$record['uid'].'"><div class="card card-body p-3">'.$rendered.'</div></div>';
<div class="collapse show" id="collapseContainer-'.$record['uid'].'"><div class="card card-body p-3">'.$rendered.'</div></div>';
}

return $flexconfOut.$newContent;
Expand All @@ -422,25 +417,4 @@ public function wrapPageModulePreview(string $previewHeader, string $previewCont
return $content;
}


/**
* Check TYPO3 version to see whether the default record templates
* are located in RecordDefault/ instead of Record/.
* See: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69769
*/
protected function hasDefaultDirectory(): bool
{
$typo3Version = new Typo3Version();

if ($typo3Version->getMajorVersion() === 10) {
return version_compare((new Typo3Version())->getVersion(), '10.4.17', '>');
}

if ($typo3Version->getMajorVersion() === 11) {
return version_compare((new Typo3Version())->getVersion(), '11.3.0', '>');
}

return false;
}

}
3 changes: 2 additions & 1 deletion Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace T3SBS\T3sbootstrap\Command;

use TYPO3\CMS\Core\Http\RequestFactory;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -320,7 +321,7 @@ private function getGoogleFonts($googleFonts, $preloadGooleFonts, $gooleFontsWei
foreach ( explode(',', $gooleFontsWeights) as $style ) {
$style = trim($style);
$zipFilename = strtolower($font).'?download=zip&subsets=latin&variants='.$style;
$zipContent = GeneralUtility::getURL(self::zipFilePath . $zipFilename);
$zipContent = GeneralUtility::makeInstance(RequestFactory::class)->request(self::zipFilePath . $zipFilename)->getBody()->getContents();
$fontArr[$fontFamily] = self::getGoogleFiles($zipContent, $localZipFile, $localZipPath);
}
}
Expand Down
5 changes: 3 additions & 2 deletions Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace T3SBS\T3sbootstrap\Command;

use TYPO3\CMS\Core\Http\RequestFactory;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -90,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$queryBuilder->expr()->eq('sys_language_uid', 0),
$queryBuilder->expr()->eq('is_siteroot', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT))
)
->execute();
->executeQuery();
$siteroots = $result->fetchAll();

foreach ($siteroots as $key=>$siteroot) {
Expand Down Expand Up @@ -246,7 +247,7 @@ public function getBootstrapFiles($bootstrapVersion): void
mkdir($localZipPath, 0777, true);
$localZipFile = GeneralUtility::getFileAbsFileName(self::localZipPath.self::localZipFile);
$zipFilename = 'v'.$bootstrapVersion.'.zip';
$zipContent = GeneralUtility::getURL(self::zipFilePath . $zipFilename);
$zipContent = GeneralUtility::makeInstance(RequestFactory::class)->request(self::zipFilePath . $zipFilename)->getBody()->getContents();
if ($zipContent) {
GeneralUtility::writeFile($localZipFile, $zipContent);
$extractTo = $localZipPath;
Expand Down
15 changes: 8 additions & 7 deletions Classes/Components/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace T3SBS\T3sbootstrap\Components;

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Service\FlexFormService;
Expand Down Expand Up @@ -97,7 +98,8 @@ public function getProcessedData(array $processedData, array $flexconf, array $p
}
}
// block
if ( empty($processedData['data']['bodytext']) && empty($processedData['data']['tx_t3sbootstrap_bodytext']) && empty($processedData['data']['header']) && empty($processedData['data']['subheader']) ) {
if ( empty($processedData['data']['bodytext']) && empty($processedData['data']['tx_t3sbootstrap_bodytext'])
&& empty($processedData['data']['header']) && empty($processedData['data']['subheader']) ) {
$cardData['block']['enable'] = FALSE;
} else {
$cardData['block']['enable'] = TRUE;
Expand Down Expand Up @@ -127,19 +129,18 @@ public function getProcessedData(array $processedData, array $flexconf, array $p
// list group
$cardData['list'] = [];
if (!empty($processedData['data']['tx_t3sbootstrap_list_item'])) {

$connectionPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_t3sbootstrap_list_item_inline');
$listGroup = $queryBuilder
->select('listitem')
->from('tx_t3sbootstrap_list_item_inline')
->where(
$queryBuilder->expr()->eq('parentid', $queryBuilder->createNamedParameter($processedData['data']['uid'], \PDO::PARAM_INT))
)
->execute()
->executeQuery()
->fetchAll();
$cardData['list'] = $listGroup;

$cardData['list'] = $listGroup;
}

// profile card
Expand Down Expand Up @@ -179,7 +180,7 @@ public function getProcessedData(array $processedData, array $flexconf, array $p
$cardClass .= ' border-'.$cardData['cardborderstyle'];
}
// parent equal Height
if ( !empty($parentflexconf['equalHeight']) ) {
if ( !empty($parentflexconf['equalHeight']) && isset($parentflexconf['card_wrapper']) && $parentflexconf['card_wrapper'] !== 'group' ) {
$cardClass .= ' h-100';
}

Expand Down
25 changes: 22 additions & 3 deletions Classes/Components/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,25 @@ public function getProcessedData(array $processedData, array $flexconf, array $p
$processedData['controls'] = $flexconf['controls'];
}
}

$processedData['ratioCalc'] = '';

if ($parentflexconf['ratio']) {
$ratioArr = explode(':', $parentflexconf['ratio']);
$processedData['ratioCalc'] = $ratioArr[1] / $ratioArr[0];
$x = str_replace(':', 'x', $parentflexconf['ratio']);
$y = $ratioArr[1].' / '.$ratioArr[0].' * 100%';
$processedData['ratioCalc'] .= '.ratio-'.$x.'{--bs-aspect-ratio:calc('.$y.');}';
$processedData['videoRatio'] = str_replace(':', 'x', $parentflexconf['ratio']);
$processedData['videoStyle'] = '';
if ( $parentflexconf['ratio'] !== '16:9') {
$processedData['videoStyle'] .= 'object-fit: cover;';
}
} else {
$processedData['ratioCalc'] = 1;
$processedData['videRatio'] = '';
$processedData['videoStyle'] = '';
}

if ( empty($processedData['files']) && !$processedData['localVideoPath'] ) {
$ratio = $parentflexconf['ratio'] ? $parentflexconf['ratio'] : '16:9';
$noImgHeight = explode(':', (string) $ratio);
Expand All @@ -124,12 +137,18 @@ public function getProcessedData(array $processedData, array $flexconf, array $p
}
$processedData['shift'] = '';
$processedData['videoShift'] = '';

if (!empty($flexconf['shift'])){
$processedData['videoStyle'] .= 'transform: translateY('.(int)$flexconf['shift'].'%);';
$negShift = (int)$flexconf['shift'] * -1;
$processedData['videoStyle'] .= 'top: '.$negShift.'% !important;';
$processedData['shift'] = (int)$flexconf['shift'] / 100;
$breakWidth = '576';
$processedData['videoShift'] = '@media(min-width: '.$breakWidth.'px){.carousel-item-'.$processedData['data']['uid'].' figure{margin-top:'.(int)$flexconf['shift'].'% !important}}';

}

$videoStyle = $processedData['videoStyle'];
$processedData['videoStyle'] = ' style="'.$videoStyle.'"';

if ( !empty($parentflexconf['swiperJs']) ) {
$processedData['swiper'] = TRUE;
}
Expand Down
Loading

0 comments on commit ea5975c

Please sign in to comment.