Skip to content

Commit

Permalink
v4.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
t3solution committed Aug 7, 2020
1 parent 9ec02a8 commit d150ca0
Show file tree
Hide file tree
Showing 28 changed files with 307 additions and 176 deletions.
58 changes: 41 additions & 17 deletions Classes/Tasks/CdnToLocal.php → Classes/Command/CdnToLocal.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,60 @@
<?php
namespace T3SBS\T3sbootstrap\Tasks;
declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
namespace T3SBS\T3sbootstrap\Command;

/**
* This file is part of the "tt_address" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

class CdnToLocal extends \TYPO3\CMS\Scheduler\Task\AbstractTask {

/**
* Command for update GRUAN access data
*/
class CdnToLocal extends Command
{

/**
* @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
* @param ConfigurationManagerInterface $configurationManager
*/
public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
$this->configurationManager = $configurationManager;
}


public function execute() {
/**
* Defines the allowed options for this command
*
* @inheritdoc
*/
protected function configure()
{
$this->setDescription('Write required CSS and JS to fileadmin/Resources/Private/');
}


/**
* Update all records
*
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

$this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$settings = $this->configurationManager->getConfiguration(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
't3sbootstrap',
'm1'
);
Expand Down Expand Up @@ -282,9 +305,9 @@ public function execute() {

}

return TRUE;
}
return 0;

}

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

Expand Down Expand Up @@ -313,4 +336,5 @@ private function writeCustomFile($customPath, $customFileName, $cdnPath, $extend
GeneralUtility::writeFile($customFile, $customContent);
}

}

}
65 changes: 47 additions & 18 deletions Classes/Tasks/Scss.php → Classes/Command/CustomScss.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,70 @@
<?php
namespace T3SBS\T3sbootstrap\Tasks;
declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
namespace T3SBS\T3sbootstrap\Command;

/**
* This file is part of the "tt_address" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

class Scss extends \TYPO3\CMS\Scheduler\Task\AbstractTask {

/**
* Command for update GRUAN access data
*/
class CustomScss extends Command
{

/**
* @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
* @param ConfigurationManagerInterface $configurationManager
*/
public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
$this->configurationManager = $configurationManager;
}


public function execute() {
/**
* Defines the allowed options for this command
*
* @inheritdoc
*/
protected function configure()
{
$this->setDescription('T3SB Custom Scss - write a custom scss file');
}


/**
* Update all records
*
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

$this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$settings = $this->configurationManager->getConfiguration(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
't3sbootstrap',
'm1'
);

if ( $settings['customScss'] ) {
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');

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

# Custom
$customDir = $settings['customScssPath'] ? $settings['customScssPath'] : 'fileadmin/T3SB/Resources/Public/SCSS/';
Expand Down Expand Up @@ -140,17 +167,18 @@ public function execute() {
$tempPath = GeneralUtility::getFileAbsFileName($tempDir);
self::deleteFilesFromDirectory($tempPath);

return TRUE;
return 0;

} else {

return FALSE;
return 1;

}

}



private function writeCustomFile($customPath, $customFileName, $settings, $name) {

$customFile = $customPath.$customFileName;
Expand Down Expand Up @@ -367,4 +395,5 @@ private function rollYourOwn($boottstrapFileName, $customPath, $settings){
}


}

}
7 changes: 4 additions & 3 deletions Classes/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\RootlineUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Backend\View\BackendTemplateView;
Expand Down Expand Up @@ -204,7 +205,7 @@ public function newAction()
*/
public function createAction(\T3SBS\T3sbootstrap\Domain\Model\Config $newConfig)
{
$this->addFlashMessage('The new configuration was created.');
$this->addFlashMessage('The new configuration was created.', '', FlashMessage::OK);

if ( self::isSiteroot() ) {
$homepageUid = (int)$_GET['id'];
Expand Down Expand Up @@ -273,7 +274,7 @@ public function editAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config)
*/
public function updateAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config)
{
$this->addFlashMessage('The configuration was updated.');
$this->addFlashMessage('The configuration was updated.', '', FlashMessage::OK);

if ( self::isSiteroot() ) {
$homepageUid = (int)$_GET['id'];
Expand All @@ -299,7 +300,7 @@ public function updateAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config)
*/
public function deleteAction(\T3SBS\T3sbootstrap\Domain\Model\Config $config)
{
$this->addFlashMessage('The object was deleted.');
$this->addFlashMessage('The object was deleted.', '', FlashMessage::INFO);
$this->configRepository->remove($config);
parent::redirect('list');
}
Expand Down
31 changes: 19 additions & 12 deletions Classes/DataProcessing/ConfigProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
}

if (!$this->processorConfiguration['disableDefaultCss']) {
self::includeRequiredFiles($processedRecordVariables);
self::includeRequiredFiles($processedRecordVariables, $webp);
}

return $this->processedData;
Expand Down Expand Up @@ -569,10 +569,11 @@ protected function getBackgroundImageUtility()
* Load required css and js files
*
* @param array $processedRecordVariables
* @param bool $webp
*
* @return void
*/
private function includeRequiredFiles($processedRecordVariables) {
private function includeRequiredFiles($processedRecordVariables, $webp) {

$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$frontendController = self::getFrontendController();
Expand Down Expand Up @@ -704,7 +705,11 @@ private function includeRequiredFiles($processedRecordVariables) {
'/fileadmin/T3SB/Resources/Public/JS/t3sbProject.js');
$pageRenderer->addJsFooterFile($projectJS);
}

if ( $webp ) {
$jsModernizr = 'EXT:t3sbootstrap/Resources/Public/Contrib/Modernizr/modernizr.js';
$jsModernizr = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($jsModernizr);
$pageRenderer->addJsFooterFile($jsModernizr);
}
}


Expand All @@ -724,26 +729,28 @@ private function writeCustomFile($customPath, $customFileName, $customContent )
$customFile = $customPath.$customFileName;

if (file_exists($customFile)) {

$customFileLength = strlen(file_get_contents($customFile));
$contentLength = strlen(trim($customContent));

if ($customFileLength != $contentLength) {
unlink($customFile);
GeneralUtility::writeFile($customFile, trim($customContent));

unlink($customFile);
GeneralUtility::writeFile($customFile, trim($customContent));
}

} else {

if (!is_dir($customPath)) {
mkdir($customPath, 0777, true);
}
GeneralUtility::writeFile($customFile, trim($customContent));

GeneralUtility::writeFile($customFile, trim($customContent));

}
}
}



}
2 changes: 1 addition & 1 deletion Classes/DataProcessing/GalleryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ protected function getImagePadding()
protected function checkMediaWidth($mediaWidth)
{

if ( $this->minimumWidth && $mediaWidth < 575 ) {
if ( $this->minimumWidth && $mediaWidth < 575 ) {
// set to 575px and therefore 100% wide on mobile (constant: minimumWidth=1)
$mediaWidth = 575;
}
Expand Down
64 changes: 64 additions & 0 deletions Classes/ExpressionLanguage/T3sbConditionFunctionsProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);

namespace T3SBS\T3sbootstrap\ExpressionLanguage;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;

/**
* Class T3sbConditionFunctionsProvider
* @internal
*/
class T3sbConditionFunctionsProvider implements ExpressionFunctionProviderInterface {


/**
* @return array
*/
public function getFunctions(): array
{
return [
$this->extconf(),
$this->browser(),
];
}

protected function extconf(): ExpressionFunction
{
return new ExpressionFunction('t3sbootstrap', function ($str) {
// Not implemented
}, function ($arguments, $str) {

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

return $extConf[$str];

});
}


protected function browser(): ExpressionFunction
{
return new ExpressionFunction('browser', function ($str) {
// Not implemented
}, function ($arguments, $str) {

$user_agent = GeneralUtility::getIndpEnv('HTTP_USER_AGENT');
$browser = 'Other';

if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) $browser = 'Opera';
elseif (strpos($user_agent, 'Edge')) $browser = 'Edge';
elseif (strpos($user_agent, 'Chrome')) $browser = 'Chrome';
elseif (strpos($user_agent, 'Safari')) $browser = 'Safari';
elseif (strpos($user_agent, 'Firefox')) $browser = 'Firefox';
elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) $browser = 'Internet Explorer';

return $str === $browser;
});

}

}
Loading

0 comments on commit d150ca0

Please sign in to comment.