Skip to content

Commit

Permalink
Merge pull request #152 from t3solution/5.1.2
Browse files Browse the repository at this point in the history
New version 5.1.2
  • Loading branch information
t3solution committed Oct 24, 2021
2 parents 4558c0a + 5696525 commit c2d5f3a
Show file tree
Hide file tree
Showing 52 changed files with 1,560 additions and 899 deletions.
9 changes: 5 additions & 4 deletions Classes/Backend/Preview/DefaultPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;

class DefaultPreviewRenderer extends StandardContentPreviewRenderer
{
Expand All @@ -34,7 +35,6 @@ public function renderPageModulePreviewHeader(GridColumnItem $item): string
$record = $item->getRecord();
$itemLabels = $item->getContext()->getItemLabels();
$outHeader = '';

$content = parent::renderPageModulePreviewContent($item);
if ( ($content && $record['CType'] === 'list')
|| ($content && $record['CType'] === 'bullets')
Expand Down Expand Up @@ -71,7 +71,6 @@ public function renderPageModulePreviewHeader(GridColumnItem $item): string
. $hiddenHeaderNote . '</strong><br />';
}

$info = '';
$contentTypeLabels = $item->getContext()->getContentTypeLabels();
$contentType = $contentTypeLabels[$record['CType']];
$info = '<div style="padding:5px; border: 1px solid #563d7c; color:#563d7c; margin-bottom:5px" >'.$contentType.'</div>';
Expand Down Expand Up @@ -113,7 +112,8 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$contentType = $contentTypeLabels[$record['CType']];
if (isset($contentType)) {

$extconf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('t3sbootstrap');
$extconf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');

$maxCharacters = $extconf['previewCropMaxCharacters'];
$append = ' ...';

Expand All @@ -129,6 +129,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
}
$out .= parent::linkEditContent(parent::renderText($text), $record);
}

if ($record['CType'] == 't3sbs_gallery') {
$out .= 'Columns: '.$record['imagecols'];
if ($record['CType'] == 't3sbs_gallery') {
Expand Down Expand Up @@ -216,7 +217,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string

} else {
$message = sprintf(
$languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
$languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'),
$record['CType']
);
$out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
Expand Down
5 changes: 3 additions & 2 deletions Classes/Backend/Preview/T3sbPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;

class T3sbPreviewRenderer extends StandardContentPreviewRenderer
{
Expand Down Expand Up @@ -331,7 +332,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$flexconfOut .= '<div style="margin:5px">'. parent::linkEditContent($this->getThumbCodeUnlinked($record, 'tt_content', $field), $record) . '</div>';
}

$extconf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('t3sbootstrap');
$extconf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');

if ($extconf['previewClosedCollapsible']) {
$newContent = '<p><a class="collapsed" style="color:#c7254e" data-toggle="collapse" href="#collapseContainer-'.$record['uid'].'" role="button" aria-expanded="false" aria-controls="collapseContainer-'.$record['uid'].'">
Expand All @@ -350,7 +351,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
</span>
</span>
</a></p>
<div class="collapse in" id="collapseContainer-'.$record['uid'].'">'.$rendered.'</div>';
<div class="collapse in show" id="collapseContainer-'.$record['uid'].'">'.$rendered.'</div>';
}

return $flexconfOut.$newContent;
Expand Down
8 changes: 0 additions & 8 deletions Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
self::writeCustomFile($customPath, $customFileName, $cdnPath);
}

if ($key == 'viewportchecker') {
$customDir = 'fileadmin/T3SB/Resources/Public/JS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'jquery.viewportchecker.min.js';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jQuery-viewport-checker/'.$version.'/jquery.viewportchecker.min.js';
self::writeCustomFile($customPath, $customFileName, $cdnPath);
}

if ($key == 'animate') {
$customDir = 'fileadmin/T3SB/Resources/Public/CSS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

$bootstrapVersion = GeneralUtility::isFirstPartOfStr($settings['cdn']['bootstrap'], '5.') ? $settings['cdn']['bootstrap'] : '5.0.2';
$bootstrapVersion = str_starts_with($settings['cdn']['bootstrap'], '5.') ? $settings['cdn']['bootstrap'] : '5.1.1';

foreach (explode(',', $scssList) as $scss ) {
$customFileName = trim($scss);
Expand Down Expand Up @@ -261,7 +261,7 @@ private function writeCustomFile($customPath, $customFileName, $settings, $name)
$customContent = $name == '_variables' ? '// Overrides Bootstrap variables'.PHP_EOL.'// $enable-shadows: true;'.PHP_EOL.'// $enable-gradients: true;'.PHP_EOL.'// $enable-negative-margins: true;' : '// Your own SCSS';

if ( $settings['bootswatch'] ) {
$customContent = GeneralUtility::getURL($settings['bootswatchURL'].strtolower($settings['bootswatch']).'/'.$name.'.scss');
$customContent = file_get_contents($settings['bootswatchURL'].strtolower($settings['bootswatch']).'/'.$name.'.scss');
if ($name == '_variables') {
$customContent = str_replace(' !default', '', $customContent);
}
Expand Down
133 changes: 62 additions & 71 deletions Classes/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use T3SBS\T3sbootstrap\Domain\Repository\ConfigRepository;
use T3SBS\T3sbootstrap\Domain\Model\Config;

/**
* ConfigController
Expand Down Expand Up @@ -107,12 +110,11 @@ class ConfigController extends ActionController
*
* @param \T3SBS\T3sbootstrap\Domain\Repository\ConfigRepository $configRepository
*/
public function injectConfigRepository(\T3SBS\T3sbootstrap\Domain\Repository\ConfigRepository $configRepository)
public function injectConfigRepository(ConfigRepository $configRepository)
{
$this->configRepository = $configRepository;
}


public function initializeAction()
{
$site = self::getCurrentSite();
Expand Down Expand Up @@ -229,7 +231,7 @@ public function newAction(): void
}

} else {
$newConfig = new \T3SBS\T3sbootstrap\Domain\Model\Config();
$newConfig = new Config();
// some defaults
$newConfig = self::setDefaults($newConfig);

Expand All @@ -247,7 +249,7 @@ public function newAction(): void
* @param \T3SBS\T3sbootstrap\Domain\Model\Config $newConfig
* @return void
*/
public function createAction(\T3SBS\T3sbootstrap\Domain\Model\Config $newConfig): void
public function createAction(Config $newConfig): void
{
$newConfig->setHomepageUid($this->rootPageId);
$newConfig->setPid($this->currentUid);
Expand All @@ -265,7 +267,7 @@ public function createAction(\T3SBS\T3sbootstrap\Domain\Model\Config $newConfig)
* @param bool $updated
* @return void
*/
public function editAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config, $updated = FALSE): void
public function editAction(Config $config, $updated = FALSE): void
{
$assignedOptions = self::getFieldsOptions();
$assignedOptions['t3version'] = $this->version;
Expand All @@ -291,7 +293,7 @@ public function editAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config, $upd
* @param \T3SBS\T3sbootstrap\Domain\Model\Config $config
* @return void
*/
public function updateAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config): void
public function updateAction(Config $config): void
{
$config->setHomepageUid($this->rootPageId);
$this->configRepository->update($config);
Expand All @@ -307,7 +309,7 @@ public function updateAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config): v
* @param \T3SBS\T3sbootstrap\Domain\Model\Config $config
* @return void
*/
public function deleteAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config): void
public function deleteAction(Config $config): void
{
$this->configRepository->remove($config);
self::writeConstants();
Expand Down Expand Up @@ -401,9 +403,9 @@ public function getFieldsOptions(): array
* @param \T3SBS\T3sbootstrap\Domain\Model\Config $rootConfig
* @return \T3SBS\T3sbootstrap\Domain\Model\Config $newConfig
*/
public function getNewConfig(\T3SBS\T3sbootstrap\Domain\Model\Config $rootConfig): \T3SBS\T3sbootstrap\Domain\Model\Config
public function getNewConfig(Config $rootConfig): Config
{
$newConfig = new \T3SBS\T3sbootstrap\Domain\Model\Config();
$newConfig = new Config();

foreach ( $this->tcaColumns as $field=>$columns ) {
$var = str_replace(' ', '_', $field);
Expand All @@ -423,7 +425,7 @@ public function getNewConfig(\T3SBS\T3sbootstrap\Domain\Model\Config $rootConfig
* @param \T3SBS\T3sbootstrap\Domain\Model\Config $config
* @return array
*/
protected function compareConfig(\T3SBS\T3sbootstrap\Domain\Model\Config $config): array
protected function compareConfig(Config $config): array
{
$compare = [];

Expand Down Expand Up @@ -467,7 +469,7 @@ protected function overrideConfig(): array
$fKey = GeneralUtility::underscoredToLowerCamelCase($fKey);
$tsField = $ts['page.']['10.']['settings.']['config.'][$fKey];

if ( $tsField != $this->rootConfig->$field() && GeneralUtility::isFirstPartOfStr($tsField, '{$bootstrap.config.') != TRUE ) {
if ( $tsField != $this->rootConfig->$field() && str_starts_with($tsField, '{$bootstrap.config.') != TRUE ) {
if ( $this->rootConfig->$field() === TRUE ) {
$override[$fKey] = 'enabled';
} elseif ( $this->rootConfig->$field() === FALSE ) {
Expand Down Expand Up @@ -592,63 +594,52 @@ public function writeConstants(): void
$breakpointWidth = $this->settings['breakpoint'][$navbarBreakpoint];

$filecontent = '';
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($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($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 {

if ($rootLineArray[0]['uid'] == $rootTemplate['pid'] ){
if ($config->getGeneralRootline() || $config->getNavbarMegamenu()) {
$filecontent .= '['.$rootTemplate['pid'].' in tree.rootLineIds && '.$config->getPid().' in tree.rootLineIds]'.PHP_EOL;
} else {
$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;
}
}
}

foreach( $this->configRepository->findAll() as $config ) {
$page = GeneralUtility::makeInstance(PageRepository::class)->getPage($config->getPid());
if ( $page['hidden'] === 0 && $page['deleted'] === 0 ) {
$pages[$config->getPid()] = $page;
$configurations[$config->getPid()] = $config;
}
}

$customDir = 'fileadmin/T3SB/Configuration/TypoScript/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 't3sbconstants.typoscript';
$customFile = $customPath.$customFileName;
foreach ( $configurations as $config ) {
if ($config->getPid() == $config->getHomepageUid()) {
// is root page
if ( count($configurations) === 1 ) {
$filecontent .= self::getConstants($config, TRUE);
$filecontent .= 'bootstrap.config.navbarBreakpointWidth = '.$breakpointWidth.PHP_EOL;
} else {
$filecontent .= '['.$config->getPid().' in tree.rootLineIds]'.PHP_EOL;
$filecontent .= self::getConstants($config, TRUE);
$filecontent .= 'bootstrap.config.navbarBreakpointWidth = '.$breakpointWidth.PHP_EOL;
$filecontent .= '[END]'.PHP_EOL.PHP_EOL;
}

if (file_exists($customFile)) {
unlink($customFile);
}
if (!is_dir($customPath)) {
mkdir($customPath, 0777, true);
} else {
if ($config->getGeneralRootline()) {
$filecontent .= '['.$config->getPid().' in tree.rootLineIds]'.PHP_EOL;
} else {
$filecontent .= '[page["uid"] == '.$config->getPid().']'.PHP_EOL;
}
$filecontent .= self::getConstants($config, FALSE);
$filecontent .= '[END]'.PHP_EOL.PHP_EOL;
}
}

GeneralUtility::writeFile($customFile, $filecontent);
$customDir = 'fileadmin/T3SB/Configuration/TypoScript/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 't3sbconstants.typoscript';
$customFile = $customPath.$customFileName;

if (file_exists($customFile)) {
unlink($customFile);
}
if (!is_dir($customPath)) {
mkdir($customPath, 0777, true);
}

GeneralUtility::writeFile($customFile, $filecontent);
}
}

Expand All @@ -660,7 +651,7 @@ public function writeConstants(): void
* @param bool $isRoot
* @return string
*/
private function getConstants(\T3SBS\T3sbootstrap\Domain\Model\Config $config, $isRoot): string
private function getConstants(Config $config, $isRoot): string
{
$constants = 'bootstrap.config.uid = '.$config->getUid() .PHP_EOL;

Expand Down Expand Up @@ -731,18 +722,18 @@ private function getUtilityColors(): array
$customScssArr = GeneralUtility::trimExplode(';', $customScss['custom-variables']);
foreach( $customScssArr as $customvariables ) {
$scsscolor = GeneralUtility::trimExplode(':', $customvariables);
if ( GeneralUtility::isFirstPartOfStr($scsscolor[1], '$')
if ( str_starts_with($scsscolor[1], '$')
&& GeneralUtility::inList($defaultUtilColorsList, $scsscolor[0]) ) {
$utilColors[$scsscolor[0]] = $scsscolor[1];
} elseif (GeneralUtility::isFirstPartOfStr($scsscolor[1], '#')) {
if (GeneralUtility::isFirstPartOfStr($scsscolor[0], '$')) {
} elseif (str_starts_with($scsscolor[1], '#')) {
if (str_starts_with($scsscolor[0], '$')) {
$colors[$scsscolor[0]] = $scsscolor[1];
}
}
}
if (is_array($utilColors)) {
foreach($utilColors as $key=>$utiColor) {
if ( GeneralUtility::isFirstPartOfStr($utiColor, '$') ) {
if ( str_starts_with($utiColor, '$') ) {
$utilityColors[$key] = $colors[$utiColor];
}
}
Expand All @@ -759,11 +750,11 @@ private function getUtilityColors(): array

$defaultScssColor = GeneralUtility::trimExplode(':', $defaultVariables);
if ($defaultScssColor[1] && GeneralUtility::inList($defaultUtilColorsList, trim($defaultScssColor[0]))) {
if ( GeneralUtility::isFirstPartOfStr($defaultScssColor[1], '$')) {
if ( str_starts_with($defaultScssColor[1], '$')) {
// variable has variable
$defaultUtilColors[$defaultScssColor[0]] = trim(rtrim($defaultScssColor[1], '!default'));
} elseif (GeneralUtility::isFirstPartOfStr($defaultScssColor[1], '#')) {
if (GeneralUtility::isFirstPartOfStr($defaultScssColor[0], '$')) {
} elseif (str_starts_with($defaultScssColor[1], '#')) {
if (str_starts_with($defaultScssColor[0], '$')) {
$defaultcolors[$defaultScssColor[0]] = trim(rtrim($defaultScssColor[1], '!default'));
}
}
Expand Down Expand Up @@ -792,7 +783,7 @@ private function getUtilityColors(): array
* @param \T3SBS\T3sbootstrap\Domain\Model\Config $newConfig
* @return \T3SBS\T3sbootstrap\Domain\Model\Config $newConfig
*/
protected function setDefaults($newConfig): \T3SBS\T3sbootstrap\Domain\Model\Config
protected function setDefaults($newConfig): Config
{
$newConfig->setHomepageUid($this->currentUid);
$newConfig->setPageTitle( 'jumbotron' );
Expand Down
Loading

0 comments on commit c2d5f3a

Please sign in to comment.