Skip to content

Commit

Permalink
Merge pull request #207 from t3solution/5.1.12
Browse files Browse the repository at this point in the history
New release v5.1.12
  • Loading branch information
t3solution committed May 19, 2022
2 parents eb20405 + b5c970d commit de5aefa
Show file tree
Hide file tree
Showing 60 changed files with 753 additions and 336 deletions.
20 changes: 20 additions & 0 deletions Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;

/*
* This file is part of the TYPO3 extension t3sbootstrap.
Expand Down Expand Up @@ -53,6 +54,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
't3sbootstrap',
'm1'
);

# check FA version & settings
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');
if ( !empty($extConf['fontawesomeCss']) ) {
if ( (int)$extConf['fontawesomeCss'] < 3 ) {
# v5
if ( (int)$settings['cdn']['fontawesome'] > 5 ) {
$settings['cdn']['fontawesome'] = $settings['cdn']['fontawesome5latest'];
}
} elseif ( (int)$extConf['fontawesomeCss'] > 2 ) {
# v6
if ( (int)$settings['cdn']['fontawesome'] < 6 ) {
$settings['cdn']['fontawesome'] = $settings['cdn']['fontawesome6latest'];
}
}
} else {
$settings['cdn']['fontawesome'] = '5.15.4';
}

foreach ($settings['cdn'] as $key=>$version) {

if ($key == 'jquery') {
Expand Down
13 changes: 5 additions & 8 deletions Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ( $settings['customScss'] && array_key_exists('customScss', $extConf)
&& $extConf['customScss'] === '1' ) {


# get the Boostrap SCSS-Files
$scssList = '_accordion.scss, _alert.scss, _badge.scss, _breadcrumb.scss, _button-group.scss, _buttons.scss, _card.scss, _carousel.scss, _close.scss, _containers.scss, _dropdown.scss, _forms.scss, _functions.scss, _grid.scss, _helpers.scss, _images.scss, _list-group.scss, _mixins.scss, _modal.scss, _nav.scss, _navbar.scss, _offcanvas.scss, _pagination.scss, _placeholders.scss, _popover.scss, _progress.scss, _reboot.scss, _root.scss, _spinners.scss, _tables.scss, _toasts.scss, _tooltip.scss, _transitions.scss, _type.scss, _utilities.scss, _variables.scss, bootstrap-grid.scss, bootstrap-reboot.scss, bootstrap-utilities.scss, bootstrap.scss';

Expand Down Expand Up @@ -154,7 +152,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
# Custom
$customDir = !empty($settings['customScssPath']) ? $settings['customScssPath'] : 'fileadmin/T3SB/Resources/Public/SCSS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$result = $queryBuilder
->select('*')
Expand All @@ -167,7 +164,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$siteroots = $result->fetchAll();

foreach ($siteroots as $key=>$siteroot) {

if ($key === 0) {
$customFileName = 'custom-variables.scss';
$customFileNameOverride = 'custom.scss';
Expand Down Expand Up @@ -267,17 +263,18 @@ private function writeCustomFile($customPath, $customFileName, $settings, $name)

$customFile = $customPath.$customFileName;
$keepVariables = (int)$settings['keepVariables'];

if (file_exists($customFile)) {
$copyFile = $customPath.'_'.time().'-'.$customFileName;



if (!copy($customFile, $copyFile)) {
return FALSE;
} elseif ($keepVariables === 0) {
} elseif (empty($keepVariables)) {
unlink($customFile);
}
}

if (!file_exists($customFile) && $keepVariables === 0) {
if (!file_exists($customFile) && empty($keepVariables)) {
if (!is_dir($customPath)) {
mkdir($customPath, 0777, true);
}
Expand Down
5 changes: 2 additions & 3 deletions Classes/Components/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ public function getProcessedData(array $processedData, array $flexconf): array
$cardData['block']['enable'] = TRUE;
}
// class
$cardClass = 'card';
$cardClass .= $processedData['class'];
$cardClass .= !empty($parentflexconf['equalHeight']) ? ' h-100' : '';
$cardClass = $processedData['class'];
$cardClass .= ' card';

if ( $processedData['data']['tx_t3sbootstrap_textcolor'] ) {
$cardClass .= ' text-'.$processedData['data']['tx_t3sbootstrap_textcolor'];
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,15 @@ protected function setDefaults(Config $newConfig): Config
$newConfig->setNavbarAlignment( 'left' );
$newConfig->setNavbarBrand( 'imgText' );
$newConfig->setNavbarContainer( 'inside' );
$newConfig->setNavbarClass('bg-gradient');
$newConfig->setNavbarClass('');
$newConfig->setJumbotronEnable( 1 );
$newConfig->setJumbotronSlide( 0 );
$newConfig->setJumbotronPosition( 'below' );
$newConfig->setJumbotronContainer( 'container' );
$newConfig->setJumbotronContainerposition( 'Inside' );
$newConfig->setJumbotronCarouselInterval(5000);
$newConfig->setJumbotronCarouselPause(0);
$newConfig->setJumbotronClass( 'p-5 mb-4 bg-light bg-gradient rounded-0' );
$newConfig->setJumbotronClass( 'p-5 mb-4 bg-light rounded-0' );
$newConfig->setBreadcrumbEnable( 1 );
$newConfig->setBreadcrumbCorner( 1 );
$newConfig->setBreadcrumbPosition( 'belowJum' );
Expand Down
9 changes: 6 additions & 3 deletions Classes/DataProcessing/GalleryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,12 @@ protected function calculateMediaWidthsAndHeights()

// Set the corrected dimensions for each media element
foreach ($this->fileObjects as $key => $fileObject) {
$mediaHeight = $this->equalMediaHeight;
$mediaWidth = $this->getCroppedDimensionalProperty($fileObject, 'width')
* ($mediaHeight / max($this->getCroppedDimensionalProperty($fileObject, 'height'), 1));
$mediaHeight = $this->equalMediaHeight;
if (is_array($fileObject)) {
$fileObject = $fileObject[0];
}
$mediaWidth = $this->getCroppedDimensionalProperty($fileObject, 'width')
* ($mediaHeight / max($this->getCroppedDimensionalProperty($fileObject, 'height'), 1));

$this->mediaDimensions[$key] = [
'width' => floor($mediaWidth),
Expand Down
2 changes: 2 additions & 0 deletions Classes/Layouts/FourColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function getProcessedData(array $processedData, array $flexconf): array
$processedData = GeneralUtility::makeInstance(Gutters::class)->getGutters($processedData, $flexconf);
$processedData = GeneralUtility::makeInstance(Grid::class)->getGrid($processedData, $flexconf);

$processedData['equalHeight'] = !empty($flexconf['equalHeight']) ? ' d-flex align-items-stretch' : '';

return $processedData;
}

Expand Down
2 changes: 2 additions & 0 deletions Classes/Layouts/SixColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function getProcessedData(array $processedData, array $flexconf): array
$processedData = GeneralUtility::makeInstance(Gutters::class)->getGutters($processedData, $flexconf);
$processedData = GeneralUtility::makeInstance(Grid::class)->getGrid($processedData, $flexconf);

$processedData['equalHeight'] = !empty($flexconf['equalHeight']) ? ' d-flex align-items-stretch' : '';

return $processedData;
}

Expand Down
2 changes: 2 additions & 0 deletions Classes/Layouts/ThreeColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function getProcessedData(array $processedData, array $flexconf): array
$processedData = GeneralUtility::makeInstance(Gutters::class)->getGutters($processedData, $flexconf);
$processedData = GeneralUtility::makeInstance(Grid::class)->getGrid($processedData, $flexconf);

$processedData['equalHeight'] = !empty($flexconf['equalHeight']) ? ' d-flex align-items-stretch' : '';

return $processedData;
}

Expand Down
1 change: 1 addition & 0 deletions Classes/Layouts/TwoColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getProcessedData(array $processedData, array $flexconf, bool $we
$processedData['class'] .= ' col-image';
}
}
$processedData['equalHeight'] = !empty($flexconf['equalHeight']) ? ' d-flex align-items-stretch' : '';

return $processedData;
}
Expand Down
188 changes: 112 additions & 76 deletions Classes/Parser/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,80 +15,116 @@
*/
abstract class AbstractParser implements ParserInterface
{

public function supports(string $extension): bool
{
return false;
}

public function compile(string $file, array $settings): string
{
return $file;
}

protected function isCached(string $file, array $settings): bool
{
$cacheIdentifier = $this->getCacheIdentifier($file, $settings);
$cacheFile = $this->getCacheFile($cacheIdentifier, $settings['cache']['tempDirectory']);
$cacheFileMeta = $this->getCacheFileMeta($cacheFile);

return file_exists($cacheFile) && file_exists($cacheFileMeta);
}

protected function needsCompile(string $cacheFile, string $cacheFileMeta, array $settings): bool
{
$needCompilation = false;
$fileModificationTime = filemtime($cacheFile);
$metadata = unserialize((string) file_get_contents($cacheFileMeta), ['allowed_classes' => false]);

foreach ($metadata['files'] as $file) {
if (filemtime($file) > $fileModificationTime) {
$needCompilation = true;
break;
}
}

if (!$needCompilation && $settings['variables'] !== $metadata['variables']) {
$needCompilation = true;
}

if (!$needCompilation && $settings['options']['sourceMap'] !== $metadata['sourceMap']) {
$needCompilation = true;
}

return $needCompilation;
}

protected function getCacheFile(string $cacheIdentifier, string $tempDirectory): string
{
return $tempDirectory . $cacheIdentifier . '.css';
}

protected function getCacheFileMeta(string $filename): string
{
return $filename . '.meta';
}

protected function getCacheIdentifier(string $file, array $settings): string
{
$filehash = md5($file);
$hash = hash('sha256', $filehash . serialize($settings));
$extension = pathinfo($file, PATHINFO_EXTENSION);

return basename($file, '.' . $extension) . '-' . $hash;
}

protected function getPathSite(): string
{
return Environment::getPublicPath() . '/';
}

/**
* Clear all page caches
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException
*/
protected function clearPageCaches(): void
{
GeneralUtility::makeInstance(CacheManager::class)->flushCachesInGroup('pages');
}
/**
* @param string $extension
* @return bool
*/
public function supports(string $extension): bool
{
return false;
}

/**
* @param string $file
* @param array $settings
* @return string
*/
public function compile(string $file, array $settings): string
{
return $file;
}

/**
* @param string $file
* @param array $settings
* @return bool
*/
protected function isCached(string $file, array $settings): bool
{
$cacheIdentifier = $this->getCacheIdentifier($file, $settings);
$cacheFile = $this->getCacheFile($cacheIdentifier, $settings['cache']['tempDirectory']);
$cacheFileMeta = $this->getCacheFileMeta($cacheFile);

return file_exists($cacheFile) && file_exists($cacheFileMeta);
}

/**
* @param string $cacheFile
* @param string $cacheFileMeta
* @param array $settings
* @return bool
*/
protected function needsCompile(string $cacheFile, string $cacheFileMeta, array $settings): bool
{
$needCompilation = false;
$fileModificationTime = filemtime($cacheFile);
$metadata = unserialize((string) file_get_contents($cacheFileMeta), ['allowed_classes' => false]);

foreach ($metadata['files'] as $file) {
if (filemtime($file) > $fileModificationTime) {
$needCompilation = true;
break;
}
}

if (!$needCompilation && $settings['variables'] !== $metadata['variables']) {
$needCompilation = true;
}

if (!$needCompilation && $settings['options']['sourceMap'] !== $metadata['sourceMap']) {
$needCompilation = true;
}

return $needCompilation;
}

/**
* @param string $cacheIdentifier
* @param string $tempDirectory
* @return string
*/
protected function getCacheFile(string $cacheIdentifier, string $tempDirectory): string
{
return $tempDirectory . $cacheIdentifier . '.css';
}

/**
* @param string $filename
* @return string
*/
protected function getCacheFileMeta(string $filename)
{
return $filename . '.meta';
}

/**
* @param string $file
* @param array $settings
* @return string
*/
protected function getCacheIdentifier(string $file, array $settings): string
{
$filehash = md5($file);
$hash = hash('sha256', $filehash . serialize($settings));
$extension = pathinfo($file, PATHINFO_EXTENSION);

return basename($file, '.' . $extension) . '-' . $hash;
}

/**
* @return string
*/
protected function getPathSite(): string
{
return Environment::getPublicPath() . '/';
}

/**
* Clear all page caches
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException
*/
protected function clearPageCaches(): void
{
GeneralUtility::makeInstance(CacheManager::class)->flushCachesInGroup('pages');
}
}
13 changes: 11 additions & 2 deletions Classes/Parser/ParserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
*/
interface ParserInterface
{
public function supports(string $extension): bool;
/**
* @param string $extension
* @return bool
*/
public function supports(string $extension): bool;

public function compile(string $file, array $settings): string;
/**
* @param string $file
* @param array $settings
* @return string
*/
public function compile(string $file, array $settings): string;
}
Loading

0 comments on commit de5aefa

Please sign in to comment.