Skip to content

Commit

Permalink
Merge pull request #170 from t3solution/5.1.5
Browse files Browse the repository at this point in the history
New release v5.1.5
  • Loading branch information
t3solution authored Nov 24, 2021
2 parents e1bdd7e + bf3aab2 commit cf28faa
Show file tree
Hide file tree
Showing 66 changed files with 1,546 additions and 1,110 deletions.
58 changes: 1 addition & 57 deletions Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


/**
* Command for update GRUAN access data
* Command for update CDN to LOCAL
*/
class CdnToLocal extends Command
{
Expand Down Expand Up @@ -258,62 +258,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
self::writeCustomFile($customPath, $customFileName, $cdnPath);
}

if ($key == 'ytPlayer') {
$customDir = 'fileadmin/T3SB/Resources/Public/CSS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'jquery.mb.YTPlayer.min.css';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/font/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'ytp-regular.eot';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/font/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/font/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'ytp-regular.ttf';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/font/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'ytp-regular.woff';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/images/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'raster.png';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/images/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'raster@2x.png';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/images/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/images/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'raster_dot.png';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/images/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

$customDir = 'fileadmin/T3SB/Resources/Public/CSS/images/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'raster_dot@2x.png';
$cdnPath = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/'.$version.'/css/images/'.$customFileName;
self::writeCustomFile($customPath, $customFileName, $cdnPath);

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

if ($key == 'masonry') {
$customDir = 'fileadmin/T3SB/Resources/Public/JS/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
Expand Down
23 changes: 22 additions & 1 deletion Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/**
* Command for update GRUAN access data
* Command for update Custom SCSS
*/
class CustomScss extends Command
{
Expand Down Expand Up @@ -229,6 +229,27 @@ 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/';
$customPath = GeneralUtility::getFileAbsFileName($customDir);
$customFileName = 'bootstrap.scss';
$customFile = $customPath.$customFileName;
$customContent = GeneralUtility::getURL($customFile);
$length = strlen($customContent);

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

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

return 0;

} else {
Expand Down
20 changes: 10 additions & 10 deletions Classes/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public function listAction($deleted = FALSE, $created = FALSE, $updateSss = FALS
$assignedOptions['allConfig'] = $allConfig;
}

$assignedOptions['template'] = TRUE;
$assignedOptions['rootTemplate'] = TRUE;
if (count($this->rootTemplates) === 0) {
$assignedOptions['template'] = FALSE;
$assignedOptions['rootTemplate'] = FALSE;
}
$assignedOptions['t3version'] = $this->version;
$assignedOptions['rootConfig'] = $this->rootConfig ? TRUE : FALSE;
Expand Down Expand Up @@ -469,7 +469,7 @@ protected function overrideConfig(): array
$fKey = GeneralUtility::underscoredToLowerCamelCase($fKey);
$tsField = $ts['page.']['10.']['settings.']['config.'][$fKey];

if ( $tsField != $this->rootConfig->$field() && str_starts_with($tsField, '{$bootstrap.config.') != TRUE ) {
if ( $tsField != $this->rootConfig->$field() && str_starts_with((string)$tsField, '{$bootstrap.config.') != TRUE ) {
if ( $this->rootConfig->$field() === TRUE ) {
$override[$fKey] = 'enabled';
} elseif ( $this->rootConfig->$field() === FALSE ) {
Expand Down Expand Up @@ -722,18 +722,18 @@ private function getUtilityColors(): array
$customScssArr = GeneralUtility::trimExplode(';', $customScss['custom-variables']);
foreach( $customScssArr as $customvariables ) {
$scsscolor = GeneralUtility::trimExplode(':', $customvariables);
if ( str_starts_with($scsscolor[1], '$')
if ( str_starts_with((string)$scsscolor[1], '$')
&& GeneralUtility::inList($defaultUtilColorsList, $scsscolor[0]) ) {
$utilColors[$scsscolor[0]] = $scsscolor[1];
} elseif (str_starts_with($scsscolor[1], '#')) {
if (str_starts_with($scsscolor[0], '$')) {
} elseif (str_starts_with((string)$scsscolor[1], '#')) {
if (str_starts_with((string)$scsscolor[0], '$')) {
$colors[$scsscolor[0]] = $scsscolor[1];
}
}
}
if (is_array($utilColors)) {
foreach($utilColors as $key=>$utiColor) {
if ( str_starts_with($utiColor, '$') ) {
if ( str_starts_with((string)$utiColor, '$') ) {
$utilityColors[$key] = $colors[$utiColor];
}
}
Expand All @@ -750,11 +750,11 @@ private function getUtilityColors(): array

$defaultScssColor = GeneralUtility::trimExplode(':', $defaultVariables);
if ($defaultScssColor[1] && GeneralUtility::inList($defaultUtilColorsList, trim($defaultScssColor[0]))) {
if ( str_starts_with($defaultScssColor[1], '$')) {
if ( str_starts_with((string)$defaultScssColor[1], '$')) {
// variable has variable
$defaultUtilColors[$defaultScssColor[0]] = trim(rtrim($defaultScssColor[1], '!default'));
} elseif (str_starts_with($defaultScssColor[1], '#')) {
if (str_starts_with($defaultScssColor[0], '$')) {
} elseif (str_starts_with((string)$defaultScssColor[1], '#')) {
if (str_starts_with((string)$defaultScssColor[0], '$')) {
$defaultcolors[$defaultScssColor[0]] = trim(rtrim($defaultScssColor[1], '!default'));
}
}
Expand Down
82 changes: 32 additions & 50 deletions Classes/Controller/ConsentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* LICENSE file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Page\AssetCollector;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use T3SBS\T3sbootstrap\Utility\YouTubeRenderer;

/**
* ConsentController
Expand All @@ -28,59 +28,41 @@ class ConsentController extends ActionController
*/
public function indexAction(): void
{
$currentRecord = $this->configurationManager->getContentObject()->data['uid'];

if ( $this->settings['consent']['cookie'] && isset($_COOKIE['contentconsent_'.$currentRecord]) && $_COOKIE['contentconsent_'.$currentRecord] == 'allow' ) {

$contentConsent = TRUE;

$consentRecordUid = (int)$this->settings['consent']['contentByUid'];
$fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
$fileObjects = $fileRepository->findByRelation('tt_content', 'assets', $consentRecordUid);
if ( $fileObjects[0]->getProperties()['mime_type'] == 'video/youtube') {

if ( $this->settings['consent']['cookie'] && isset($_COOKIE['contentconsent_'.$consentRecordUid])
&& $_COOKIE['contentconsent_'.$consentRecordUid] == 'allow' ) {
$contentConsent = TRUE;
} else {
$contentConsent = FALSE;
$lazyload = $this->settings['lazyLoad'] ? 'true': 'false';
$thumbnailRecordUid = $this->configurationManager->getContentObject()->data['uid'];
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
$thumbnails = $fileRepository->findByRelation('tt_content', 'consentpreviewimage', $thumbnailRecordUid);
}
$autoplay = $fileObjects[0]->getProperties()['autoplay'];
$videoId = GeneralUtility::makeInstance(YouTubeRenderer::class)->render($fileObjects[0]);
$mute = $autoplay ? 1 : 0;
$ratioArr = explode('/',$this->settings['consent']['autoSize']);
$params = '?autoplay='.$autoplay.'&loop=0&playlist='.$videoId.'&mute='.$mute.'&rel=0&showinfo=0&controls=1&modestbranding=1';
$assignedValues = [
'contentConsent' => $contentConsent,
'thumbnail' => $thumbnails[0],
'ytuid' => $videoId,
'params' => $params,
'ratio' => trim($ratioArr[1]).'x'.trim($ratioArr[0]),
'isYouTube' => TRUE,
];
} else {

$contentConsent = FALSE;

$lazyload = $this->settings['lazyLoad'] ? 'true': 'false';
if($lazyload)
GeneralUtility::makeInstance(AssetCollector::class)
->addInlineJavaScript('contentconsent', $lazyload);

$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
$thumbnails = $fileRepository->findByRelation('tt_content', 'consentpreviewimage', $currentRecord);
}

if ( $this->settings['consent']['autoSize'] ) {
$inlineJS = '
var thumbnail = $("#c'.$currentRecord.' .content-consent.background-image");
if (thumbnail.length) {
var thumbHeight = thumbnail.outerWidth() * '.$this->settings['consent']['autoSize'].';
thumbnail.css("min-height", parseInt(thumbHeight)+"px");
}';

if($inlineJS)
GeneralUtility::makeInstance(AssetCollector::class)
->addInlineJavaScript('contentconsentthumbnailautosize-'.$currentRecord, $inlineJS);
$assignedValues = [
'isYouTube' => FALSE,
];
}

$assignedValues = [
'currentRecord' => $currentRecord,
'contentConsent' => $contentConsent,
'thumbnail' => $thumbnails[0],
];
$this->view->assignMultiple($assignedValues);
}


/**
* Displays the selected result with ajax
*
* @return void
*/
public function ajaxAction(): void
{
$post = GeneralUtility::_POST();
$currentRecord = $post['currentRecord'];
if ($this->settings['consent']['cookie']) {
$cookieExpire = $this->settings['cookieExpire'] ? (int)$this->settings['cookieExpire'] : 30;
setcookie('contentconsent_'.$currentRecord, 'allow', time() + (86400 * $cookieExpire), '/');
}
}
}
Loading

0 comments on commit cf28faa

Please sign in to comment.