Skip to content

Commit

Permalink
Merge pull request #115 from t3solution/4.6.0
Browse files Browse the repository at this point in the history
New version 4.6.0
  • Loading branch information
t3solution authored Jun 3, 2021
2 parents abd8dfe + d6f1e1c commit c697a89
Show file tree
Hide file tree
Showing 45 changed files with 1,333 additions and 272 deletions.
16 changes: 14 additions & 2 deletions Classes/Backend/Preview/T3sbPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Page\PageRenderer;

class T3sbPreviewRenderer extends StandardContentPreviewRenderer
{
Expand Down Expand Up @@ -99,6 +100,11 @@ public function renderPageModulePreviewHeader(GridColumnItem $item): string

public function renderPageModulePreviewContent(GridColumnItem $item): string
{
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule(
'TYPO3/CMS/T3sbootstrap/Bootstrap',
'function() { console.log("Loaded bootstrap.js by t3sbootstrap."); }'
);

$content = parent::renderPageModulePreviewContent($item);
$context = $item->getContext();
Expand Down Expand Up @@ -159,6 +165,12 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
if ( $flexconf['link'] ) {
$out .= '<br />- Link: '.$flexconf['link'];
}
if ( $flexconf['owlCarousel'] ) {
$out .= '<br />- OWL Carousel';
$out .= '<br />- OWL Style: '.$flexconf['owlStyle'];
if ($flexconf['owlStyle'] == 1)
$out .= '<br />- OWL Line: '.$flexconf['owlLine'];
}
if ( $flexconf['multislider'] ) {
$out .= '<br />- Multislider';
}
Expand Down Expand Up @@ -297,7 +309,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$extconf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('t3sbootstrap');

if ($extconf['previewClosedCollapsible']) {
$content = '<p><a style="color:#c7254e" data-toggle="collapse" href="#collapseContainer-'.$record['uid'].'" role="button" aria-expanded="false" aria-controls="collapseExample">
$content = '<p><a class="collapsed" style="color:#c7254e" 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"><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>
Expand All @@ -306,7 +318,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
</a></p>
<div class="collapse" id="collapseContainer-'.$record['uid'].'">'.$content . $rendered.'</div>';
} else {
$content = '<p><a style="color:#c7254e" data-toggle="collapse" href="#collapseContainer-'.$record['uid'].'" role="button" aria-expanded="true" aria-controls="collapseExample">
$content = '<p><a style="color:#c7254e" 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"><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>
Expand Down
16 changes: 16 additions & 0 deletions Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
$cdnPath = 'https://cdn.jsdelivr.net/npm/lightcase@'.$version.'/src/js/lightcase.min.js';
self::writeCustomFile($customPath, $customFileName, $cdnPath);
}
if ($key == 'owlCarousel') {
$customDir = 'fileadmin/T3SB/Resources/Public/CSS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'owl.carousel.min.css';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/'.$version.'/assets/owl.carousel.min.css';
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customFileName = 'owl.theme.default.css';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/'.$version.'/assets/owl.theme.default.css';
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/JS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'owl.carousel.js';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/'.$version.'/owl.carousel.js';
self::writeCustomFile($customPath, $customFileName, $cdnPath);
}

if ($key == 'cookieconsent') {
$customDir = 'fileadmin/T3SB/Resources/Public/CSS/';
Expand Down
57 changes: 39 additions & 18 deletions Classes/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\PageRenderer;

/**
* ConfigController
Expand Down Expand Up @@ -94,6 +95,12 @@ class ConfigController extends ActionController
*/
protected $version;

/**
* rootTemplates
*
* @var array
*/
protected $rootTemplates;

/**
* Inject a configRepository repository to enable DI
Expand All @@ -117,6 +124,21 @@ public function initializeAction()
$this->rootConfig = $this->configRepository->findOneByPid($this->rootPageId);
$typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
$this->version = (int)$typo3Version->getVersion();

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_template');
$this->rootTemplates = $queryBuilder
->select('uid','pid', 'constants')
->from('sys_template')
->where(
$queryBuilder->expr()->eq('root', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT))
)
->execute()->fetchAll();

$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule(
'TYPO3/CMS/T3sbootstrap/Bootstrap',
'function() { console.log("Loaded bootstrap.js by t3sbootstrap!"); }'
);
}


Expand Down Expand Up @@ -147,6 +169,10 @@ public function listAction($deleted = FALSE, $created = FALSE, $updateSss = FALS
$assignedOptions['allConfig'] = $allConfig;
}

$assignedOptions['template'] = TRUE;
if (count($this->rootTemplates) === 0) {
$assignedOptions['template'] = FALSE;
}
$assignedOptions['t3version'] = $this->version;
$assignedOptions['rootConfig'] = $this->rootConfig ? TRUE : FALSE;
$assignedOptions['config'] = $this->configRepository->findOneByPid($this->currentUid);
Expand Down Expand Up @@ -567,40 +593,38 @@ public function writeConstants(): void
$persistenceManager = $this->objectManager->get("TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager");
$persistenceManager->persistAll();

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_template');
$rootTemplates = $queryBuilder
->select('uid','pid', 'constants')
->from('sys_template')
->where(
$queryBuilder->expr()->eq('root', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT))
)
->execute()->fetchAll();
if ( count($this->rootTemplates) ) {

$configRepository = $this->configRepository->findOneByPid($this->rootPageId);
$navbarBreakpoint = $configRepository->getNavbarBreakpoint();
$breakpointWidth = $this->settings['breakpoint'][$navbarBreakpoint];

if ( count($rootTemplates) ) {
$filecontent = '';
foreach ($rootTemplates as $key=>$rootTemplate) {
foreach ($this->rootTemplates as $key=>$rootTemplate) {
foreach ( $this->configRepository->findAll() as $config ) {
$rootLineArray = GeneralUtility::makeInstance(RootlineUtility::class, $config->getPid())->get();
if ( $config->getPid() == $rootTemplate['pid'] ) {

if ( count($rootTemplates) == 1 ) {
$filecontent .= self::getConstants($config, TRUE).PHP_EOL;
if ( count($this->rootTemplates) == 1 ) {
$filecontent .= self::getConstants($config, TRUE);
$filecontent .= 'bootstrap.config.navbarBreakpointWidth = '.$breakpointWidth.PHP_EOL.PHP_EOL;
} else {
if ($rootLineArray[0]['uid'] == $rootTemplate['pid'] ){
$filecontent .= '['.$rootTemplate['pid'].' in tree.rootLineIds]'.PHP_EOL;
$filecontent .= self::getConstants($config, TRUE);
$filecontent .= 'bootstrap.config.navbarBreakpointWidth = '.$breakpointWidth.PHP_EOL;
$filecontent .= '[END]'.PHP_EOL.PHP_EOL;
}
}
} else {
if ( count($rootTemplates) == 1 ) {
if ( count($this->rootTemplates) == 1 ) {
if ($rootLineArray[0]['uid'] == $rootTemplate['pid'] ){
if ($config->getGeneralRootline() || $config->getNavbarMegamenu()) {
$filecontent .= '['.$config->getPid().' in tree.rootLineIds]'.PHP_EOL;
} else {
$filecontent .= '[page["uid"] == '.$config->getPid().']'.PHP_EOL;
}
$filecontent .= self::getConstants($config, FALSE);
$filecontent .= 'bootstrap.config.navbarBreakpointWidth = '.$breakpointWidth.PHP_EOL;
$filecontent .= '[END]'.PHP_EOL.PHP_EOL;
}
} else {
Expand All @@ -613,6 +637,7 @@ public function writeConstants(): void
$filecontent .= '['.$rootTemplate['pid'].' in tree.rootLineIds && page["uid"] == '.$config->getPid().']'.PHP_EOL;
}
$filecontent .= self::getConstants($config, FALSE);
$filecontent .= 'bootstrap.config.navbarBreakpointWidth = '.$breakpointWidth.PHP_EOL;
$filecontent .= '[END]'.PHP_EOL.PHP_EOL;
}
}
Expand Down Expand Up @@ -912,8 +937,4 @@ protected function getTreeList($id, $depth, $begin = 0, $permsClause = ''): stri
return (string)$theList;
}





}
45 changes: 29 additions & 16 deletions Classes/DataProcessing/BootstrapProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,21 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
$parentContainer = $statement['tx_container_parent'];
}

$processedData['dataAnimate'] = FALSE;
$processedData['isAnimateCss'] = FALSE;

$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');

$defaultHelper = GeneralUtility::makeInstance(DefaultHelper::class);
$classHelper = GeneralUtility::makeInstance(ClassHelper::class);
$styleHelper = GeneralUtility::makeInstance(StyleHelper::class);
$wrapperHelper = GeneralUtility::makeInstance(WrapperHelper::class);

# used for js-conditions
# used for js-conditions - deprecated
$processedData['winWidth'] = (int)$processorConfiguration['breakpoint.'][$contentObjectConfiguration['settings.']['breakpoint']];
// used for js-conditions
$navbarBreakpointWidth = (int)$processorConfiguration['breakpoint.'][$contentObjectConfiguration['settings.']['breakpoint']];
$processedData['navbarBreakpointWidth'] = $navbarBreakpointWidth;

// class
$class = $classHelper->getAllClass($processedData['data'], $flexconf, $extConf);
Expand All @@ -79,7 +85,6 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
$style = $styleHelper->getBgColor($processedData['data']);
$processedData['style'] = $processedData['style'] ? $processedData['style'].' '.$style : $style;


/**
* Grid System
*/
Expand Down Expand Up @@ -169,6 +174,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
foreach($statement as $element) {
$filesFromRepository[$element['uid']] = $fileRepository->findByRelation('tt_content', 'image', $element['uid']);
}

$processedData['carouselSlides'] = $filesFromRepository;
}
}
Expand Down Expand Up @@ -337,21 +343,31 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
$processedData['style'] .= ' min-height:'.$noImgHeight.'px;';
$processedData['style'] .= $flexconf['captionVAlign'] == 'end' ? ' padding-bottom:50px;' : '';
}
$processedData['zoom'] = $parentflexconf['zoom'];

if ( $parentflexconf['multislider'] ) {
$processedData['multislider'] = TRUE;
}

$processedData['zoom'] = $parentflexconf['zoom'];
$carouselRatioArr = explode(':', $parentflexconf['ratio']);
if ( !empty($carouselRatioArr[0]) ) {
$processedData['ratio'] = $parentflexconf['ratio'];
if ($flexconf['shift']){
$processedData['shift'] = (int)$flexconf['shift'] / 100;
} else {
$processedData['shift'] = '';
if ( $parentflexconf['owlCarousel'] ) {
$processedData['owlCarousel'] = TRUE;
$processedData['owlStyle'] = $parentflexconf['owlStyle'];
$processedData['style'] = '';
if ( (int) $parentflexconf['owlStyle'] == 1 && $flexconf['bgOverlayOwl'] ) {
$processedData['style'] = $styleHelper->getBgColor($processedData['data']);
}
$processedData['owlLine'] = $parentflexconf['owlLine'];
$processedData['zoom'] = '';
}
$processedData['ratio'] = '';
if ($parentflexconf['ratio']) {
$carouselRatioArr = explode(':', (string) $parentflexconf['ratio']);
if ( !empty($carouselRatioArr[0]) ) {
$processedData['ratio'] = $parentflexconf['ratio'];
}
} else {
$processedData['ratio'] = '';
}
$processedData['shift'] = '';
if ($flexconf['shift']){
$processedData['shift'] = (int)$flexconf['shift'] / 100;
}
}

Expand Down Expand Up @@ -383,7 +399,6 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
*/
if ($processedData['data']['CType']) {
if ( substr($processedData['data']['CType'], 0, 4) == 'menu' ) {

$processedData['menudirection'] = ' '.$flexconf['menudirection'];
$processedData['menupills'] = $flexconf['menupills'] ? ' nav-pills' :'';
$processedData['menuHorizontalAlignment'] = $flexconf['menudirection'] == 'flex-row'
Expand Down Expand Up @@ -562,8 +577,6 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
// disable animateCss (conflict)
$processedData['data']['tx_t3sbootstrap_animateCss'] = FALSE;
}
$processedData['dataAnimate'] = FALSE;
$processedData['isAnimateCss'] = FALSE;
if ($processedData['data']['tx_t3sbootstrap_animateCss'] && $extConf['animateCss'] ) {
// add to class
if( $processedData['data']['tx_t3sbootstrap_animateCssRepeat'] ) {
Expand Down
13 changes: 11 additions & 2 deletions Classes/DataProcessing/ConfigProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,17 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
$processedData['config']['navbar']['enable'] = $processedRecordVariables['navbarEnable'];
$processedData['config']['navbar']['sectionMenu'] = $processedRecordVariables['navbarSectionmenu'] ? ' section-menu' : '';
$processedData['config']['navbar']['brand'] = $processedRecordVariables['navbarBrand'];

if ( $frontendController->rootLine[1]['doktype'] == 4) {
$processedData['config']['navbar']['clickableparent'] = 1;
} else {
$processedData['config']['navbar']['clickableparent'] = $processedRecordVariables['navbarClickableparent'];
}
if ( $processedData['config']['navbar']['clickableparent'] && $processedRecordVariables['navbarPlusicon']) {
$processedData['config']['navbar']['navbarPlusicon'] = 0;
} else {
$processedData['config']['navbar']['navbarPlusicon'] = $processedRecordVariables['navbarPlusicon'];
}
$processedData['config']['navbar']['image'] = $processedRecordVariables['navbarImage']
? $processedRecordVariables['navbarImage'] : $contentObjectConfiguration['settings.']['navbar.']['image.']['defaultPath'];
$processedData['config']['navbar']['toggler'] = $processedRecordVariables['navbarToggler'];
Expand Down Expand Up @@ -429,8 +435,11 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
$processedData['config']['expandedcontentBottom']['class'] = trim($processedRecordVariables['expandedcontentClassbottom']);
}

// used for js-conditions
// used for js-conditions - deprecated
$processedData['winWidth'] = (int)$processorConfiguration['breakpoint.'][$processedRecordVariables['navbarBreakpoint']];
// used for js-conditions
$navbarBreakpointWidth = (int)$processorConfiguration['breakpoint.'][$processedRecordVariables['navbarBreakpoint']];
$processedData['navbarBreakpointWidth'] = $navbarBreakpointWidth;

return $processedData;
}
Expand Down Expand Up @@ -542,7 +551,7 @@ function getTreePids($parent = 0): array
$childPids = $queryGenerator->getTreeList($parent, 999999, 0, 1);
$childPids = explode(',',$childPids );

return $childPids;
return $childPids;
}

}
1 change: 0 additions & 1 deletion Classes/Domain/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ class Config extends AbstractEntity
*/
protected $navbarClickableparent = false;


/**
* navbarDropdownAnimate
*
Expand Down
10 changes: 8 additions & 2 deletions Classes/Helper/WrapperHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public function getBackgroundWrapper($processedData, $flexconf, $cdnEnable=null,
if ($inlineJS)
GeneralUtility::makeInstance(AssetCollector::class)
->addInlineJavaScript('background-video-'.$processedData['data']['uid'], $inlineJS);


$events = $flexconf;
$events['videoAutoPlay'] = $file->getProperties()['autoplay'];
$events['uid'] = $processedData['data']['uid'];
Expand Down Expand Up @@ -389,7 +389,13 @@ public function getCarouselContainer($processedData, $flexconf): array
->addInlineJavaScript('multisliderinlinejs-'.$processedData['data']['uid'], $inlineJS);

$processedData['multislider'] = TRUE;
}

if ( $flexconf['owlCarousel'] ) {
$processedData['owlCarousel'] = TRUE;
$processedData['owlAnimation'] = $flexconf['owlAnimation'];
$processedData['owlNumber'] = $flexconf['owlNumber'];
$processedData['owlStyle'] = $flexconf['owlStyle'];
}

$processedData['maxWidth'] = $flexconf['width'].'px';
Expand Down
Loading

0 comments on commit c697a89

Please sign in to comment.