Skip to content

Commit

Permalink
Merge pull request #233 from t3solution/5.1.18
Browse files Browse the repository at this point in the history
New release v5.1.18
  • Loading branch information
t3solution authored Jul 25, 2022
2 parents 97059ff + 08f8920 commit f8bff84
Show file tree
Hide file tree
Showing 47 changed files with 2,344 additions and 1,821 deletions.
19 changes: 7 additions & 12 deletions Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function injectConfigurationManager(ConfigurationManagerInterface $config
*/
protected function configure()
{
$this->setDescription('Write required CSS and JS to fileadmin/Resources/Public/');
$this->setDescription('Write required CSS and JS to fileadmin/Resources/Public/');
}


Expand Down Expand Up @@ -87,13 +87,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$customDir = 'fileadmin/T3SB/Resources/Public/CSS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'bootstrap.min.css';

if ($settings['cdn']['bootswatch']) {
$bootswatchTheme = $settings['cdn']['bootswatch'];
$cdnPath = 'https://cdn.jsdelivr.net/npm/bootswatch@'.$settings['cdn']['bootstrap'].'/dist/'.$bootswatchTheme.'/'.$customFileName;
$cdnPath = 'https://cdn.jsdelivr.net/npm/bootswatch@'.$version.'/dist/'.$bootswatchTheme.'/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath, true);
} else {
$cdnPath = 'https://cdn.jsdelivr.net/npm/bootstrap@'.$settings['cdn']['bootstrap'].'/dist/css/'.$customFileName;
$cdnPath = 'https://cdn.jsdelivr.net/npm/bootstrap@'.$version.'/dist/css/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath, true);
}

Expand All @@ -102,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$customFileName = 'bootstrap.min.js';
$cdnPath = 'https://cdn.jsdelivr.net/npm/bootstrap@'.$version.'/dist/js/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);
$customFileName = 'bootstrap.bundle.min.js';
$cdnPath = 'https://cdn.jsdelivr.net/npm/bootstrap@'.$version.'/dist/js/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);
}

if ($key == 'popperjs') {
Expand Down Expand Up @@ -263,25 +265,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

private function writeCustomFile($customPath, $customFileName, $cdnPath, $extend=false ) {

$customFile = $customPath.$customFileName;
$customContent = GeneralUtility::getURL($cdnPath);

if ($extend && str_contains($customContent, '/*#')) {

if ($extend && str_contains( (string)$customContent, '/*#')) {
$customContentArr = explode('/*#' , $customContent);
$customContent = $customContentArr[0];

} elseif (str_contains((string)$customContent, '//#')) {

$customContentArr = explode('//#' , $customContent);
$customContent = $customContentArr[0];
}

if (file_exists($customFile)) {
unlink($customFile);
}

if (!is_dir($customPath)) {
mkdir($customPath, 0777, true);
}
Expand Down
171 changes: 60 additions & 111 deletions Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;

/*
* This file is part of the TYPO3 extension t3sbootstrap.
Expand All @@ -22,6 +20,16 @@
*/
class CustomScss extends Command
{
const localZipFile = 't3sb.zip';
const localZipPath = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/';
const zipFilePath = 'https://github.com/twbs/bootstrap/archive/';


public function initializeAction()
{
parent::initializeAction();
}


public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
Expand All @@ -47,7 +55,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

$this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$settings = $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
Expand All @@ -57,97 +64,10 @@ protected function execute(InputInterface $input, OutputInterface $output)

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

if ( $settings['customScss'] && array_key_exists('customScss', $extConf)
&& $extConf['customScss'] === '1' ) {
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';

$mixinsList = '_alert.scss, _backdrop.scss, _border-radius.scss, _box-shadow.scss, _breakpoints.scss, _buttons.scss, _caret.scss, _clearfix.scss, _color-scheme.scss, _container.scss, _deprecate.scss, _forms.scss, _gradients.scss, _grid.scss, _image.scss, _list-group.scss, _lists.scss, _pagination.scss, _reset-text.scss, _resize.scss, _table-variants.scss, _text-truncate.scss, _transition.scss, _utilities.scss, _visually-hidden.scss';

$utilitiesList = '_api.scss';

$formsList = '_floating-labels.scss, _form-check.scss, _form-control.scss, _form-range.scss, _form-select.scss, _form-text.scss, _input-group.scss, _labels.scss, _validation.scss';

$helpersList = '_clearfix.scss, _colored-links.scss, _position.scss, _ratio.scss, _stacks.scss, _stretched-link.scss, _text-truncation.scss, _visually-hidden.scss, _vr.scss';

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

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

foreach (explode(',', $scssList) as $scss ) {
$customFileName = trim($scss);
$customFile = $customPath.$customFileName;
$cdnPath = 'https://raw.githubusercontent.com/twbs/bootstrap/v'.trim($bootstrapVersion).'/scss/'.$customFileName;
$customContent = GeneralUtility::getURL($cdnPath);
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
}

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/mixins/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

foreach (explode(',', $mixinsList) as $mixins ) {
$customFileName = trim($mixins);
$customFile = $customPath.$customFileName;
$cdnPath = 'https://raw.githubusercontent.com/twbs/bootstrap/v'.trim($bootstrapVersion).'/scss/mixins/'.$customFileName;
$customContent = GeneralUtility::getURL($cdnPath);
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
}

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/utilities/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

foreach (explode(',', $utilitiesList) as $utils ) {
$customFileName = trim($utils);
$customFile = $customPath.$customFileName;
$cdnPath = 'https://raw.githubusercontent.com/twbs/bootstrap/v'.trim($bootstrapVersion).'/scss/utilities/'.$customFileName;
$customContent = GeneralUtility::getURL($cdnPath);
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
}

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/forms/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);


foreach (explode(',', $formsList) as $forms ) {
$customFileName = trim($forms);
$customFile = $customPath.$customFileName;
$cdnPath = 'https://raw.githubusercontent.com/twbs/bootstrap/v'.trim($bootstrapVersion).'/scss/forms/'.$customFileName;
$customContent = GeneralUtility::getURL($cdnPath);
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
}

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/helpers/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

foreach (explode(',', $helpersList) as $helpers ) {
$customFileName = trim($helpers);
$customFile = $customPath.$customFileName;
$cdnPath = 'https://raw.githubusercontent.com/twbs/bootstrap/v'.trim($bootstrapVersion).'/scss/helpers/'.$customFileName;
$customContent = GeneralUtility::getURL($cdnPath);
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
}

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/vendor/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);

$customFileName = '_rfs.scss';
$customFile = $customPath.$customFileName;
$cdnPath = 'https://raw.githubusercontent.com/twbs/bootstrap/v'.trim($bootstrapVersion).'/scss/vendor/_rfs.scss';
$customContent = GeneralUtility::getURL($cdnPath);
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
$bootstrapVersion = str_starts_with($settings['cdn']['bootstrap'], '5.') ? $settings['cdn']['bootstrap'] : '5.1.13';
self::getSccFiles($bootstrapVersion);

# Custom
$customDir = !empty($settings['customScssPath']) ? $settings['customScssPath'] : 'fileadmin/T3SB/Resources/Public/SCSS/';
Expand Down Expand Up @@ -199,13 +119,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($key === 0) {
$includeContent = '
@import "../../'.$customDir.'custom-variables";
@import "../../fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/bootstrap";
@import "../../'.self::localZipPath.'scss/bootstrap";
@import "../../'.$customDir.'custom";
';
} else {
$includeContent = '
@import "../../'.$customDir.'custom-variables-'.$siteroot['uid'].'";
@import "../../fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/bootstrap";
@import "../../'.self::localZipPath.'scss/bootstrap";
@import "../../'.$customDir.'custom-'.$siteroot['uid'].'";
';
}
Expand All @@ -217,43 +137,45 @@ protected function execute(InputInterface $input, OutputInterface $output)
$tempPath = GeneralUtility::getFileAbsFileName('typo3temp/assets/t3sbootstrap/css/');
self::deleteFilesFromDirectory($tempPath);

$customDir = 'fileadmin/T3SB/Resources/Public/Contrib/Bootstrap/scss/';
$customDir = self::localZipPath.'scss/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'bootstrap.scss';
$customFile = $customPath.$customFileName;
$customContent = GeneralUtility::getURL($customFile);
$length = strlen($customContent);
$length = 0;
if ($customContent) {
$length = strlen($customContent);
}

foreach ( $settings['optimize'] as $component=>$import ) {
if (!$import) {
if (!$import && $customContent) {
$find = '@import "'.$component.'";';
$replace = '// @import "'.$component.'";';
$customContent = str_replace($find, $replace, $customContent);
}
}

if ($length < strlen($customContent)) {
if ($customContent && $length < strlen($customContent)) {
if (file_exists($customFile)) unlink($customFile);
if (!is_dir($customPath)) mkdir($customPath, 0777, true);
GeneralUtility::writeFile($customFile, $customContent);
}

return 0;
if ( is_dir(GeneralUtility::getFileAbsFileName(self::localZipPath.'scss')) ) {

} else {
return 0;

$message = GeneralUtility::makeInstance(FlashMessage::class,
'You have to activate SCSS in the EM config!',
'T3S Bootstrap - Custom SCSS',
FlashMessage::ERROR
);
} else {
throw new \InvalidArgumentException('Check the bootstrap version in the constant editor for validity!', 1657204821);

$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
$messageQueue->addMessage($message);
return 1;
}

return 1;
} else {

throw new \InvalidArgumentException('You have to activate SCSS in the EM config!', 1657204821);

return 1;
}

}
Expand Down Expand Up @@ -307,7 +229,6 @@ private function deleteFilesFromDirectory($directory){
}



/**
* remove dirs
*/
Expand Down Expand Up @@ -359,4 +280,32 @@ private function rmDir(string $path) : int
return 0;
}


public function getSccFiles($bootstrapVersion): void
{
if ( is_dir(GeneralUtility::getFileAbsFileName(self::localZipPath.'scss')) ) {
self::rmDir(GeneralUtility::getFileAbsFileName(self::localZipPath.'scss'));
}
$zipFilename = 'v'.$bootstrapVersion.'.zip';
$zip_file = GeneralUtility::getFileAbsFileName(self::localZipPath.self::localZipFile);
$zipContent = GeneralUtility::getURL(self::zipFilePath . $zipFilename);
GeneralUtility::writeFile($zip_file, $zipContent);
$extractTo = GeneralUtility::getFileAbsFileName(self::localZipPath);
$zip = new \ZipArchive;
if ($zip->open($zip_file) === TRUE) {
$zip->extractTo($extractTo);
$zip->close();
} else {
throw new \InvalidArgumentException('Sorry ZIP creation failed at this time!', 1657464667);
}
$renameFrom = GeneralUtility::getFileAbsFileName(self::localZipPath.'bootstrap-'.$bootstrapVersion.'/scss');
$renameTo = GeneralUtility::getFileAbsFileName(self::localZipPath.'scss');
if ( is_dir($renameFrom) ) {
rename($renameFrom, $renameTo);
}
self::rmDir(GeneralUtility::getFileAbsFileName(self::localZipPath.'bootstrap-'.$bootstrapVersion));
$zipFile = GeneralUtility::getFileAbsFileName(self::localZipPath.self::localZipFile);
if (file_exists($zipFile)) unlink($zipFile);
}

}
12 changes: 11 additions & 1 deletion Classes/Components/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function getProcessedData(array $processedData, array $flexconf, array $p
|| $file->getMimeType() == 'video/ogg' || $file->getMimeType() == 'video/flac' || $file->getMimeType() == 'video/opus') {
$processedData['localVideoPath'] = '/'.$file->getStorage()->getConfiguration()['basePath'].substr($file->getIdentifier(), 1);
}
$processedData['autoplay'] = $file->getProperties()['autoplay'];
$processedData['loop'] = $flexconf['loop'];
$processedData['muted'] = $file->getProperties()['autoplay'] ? 1 : $flexconf['muted'];
$processedData['playsinline'] = $flexconf['playsinline'];
if ($processedData['data']['header'] || $processedData['data']['bodytext']
|| ( $processedData['data']['header_link'] && $parentflexconf['link'] == 'button') ) {
$processedData['controls'] = 0;
} else {
$processedData['controls'] = $flexconf['controls'];
}
}
if ($parentflexconf['ratio']) {
$ratioArr = explode(':', $parentflexconf['ratio']);
Expand Down Expand Up @@ -148,7 +158,7 @@ public function getCarouselCaptionStyle( $flexconf, $animate ): string
} else {
$style .= $flexconf['captionVAlign'] == 'top' ? ' top:0;' : '';
$style .= $flexconf['captionVAlign'] == 'center' ? ' bottom:0;' : '';
#$style .= $flexconf['captionVAlign'] == 'end' ? ' padding-bottom:50px;' : '';
$style .= $flexconf['captionVAlign'] == 'end' ? ' padding-bottom:50px;' : '';
$captionStyle = '';
}
if ($animate){
Expand Down
Loading

0 comments on commit f8bff84

Please sign in to comment.