Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace KayStrobach\Dyncss\Hooks\Backend\Toolbar;

use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Backend\Routing\UriBuilder;
Expand All @@ -26,10 +27,9 @@ class ClearCacheActionsHook implements ClearCacheActionsHookInterface
public function manipulateCacheActions(&$cacheActions, &$optionValues)
{
$clearCacheSystemUser = (bool)($this->getBackendUser()->getTSConfig()['options.']['clearCache.']['system'] ?? false);
$isDevelopment = GeneralUtility::getApplicationContext()->isDevelopment();
$clearCacheSystemSys = (bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true;
$isDevelopment = Environment::getContext()->isDevelopment();
$isAdmin = $this->getBackendUser()->isAdmin();
if ($clearCacheSystemUser || $isDevelopment || ($clearCacheSystemSys && $isAdmin)) {
if ($clearCacheSystemUser || $isDevelopment || $isAdmin) {
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriParameters = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1];
$translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.';
Expand All @@ -53,5 +53,4 @@ protected function getBackendUser()
{
return $GLOBALS['BE_USER'];
}

}
14 changes: 8 additions & 6 deletions Classes/Parser/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace KayStrobach\Dyncss\Parser;

use KayStrobach\Dyncss\Utilities\ApplicationContext;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\ArrayUtility;

/**
* @todo fix type hinting in @param comments
Expand Down Expand Up @@ -38,6 +36,9 @@ abstract class AbstractParser implements ParserInterface
* @var array
*/
protected $config = [];
protected $cacheFilename = '';
protected $inputFilename = '';
protected $outputFilename = '';

/**
* @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
Expand All @@ -59,7 +60,7 @@ public function __construct()
*/
protected function initEmConfiguration()
{
$this->config = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dyncss']);
$this->config = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['dyncss'] ?? [];
}

/**
Expand Down Expand Up @@ -292,13 +293,15 @@ public function compileFile($inputFilename, $outputFilename = null)
$this->outputFilename = $outputFilename;
$this->cacheFilename = $cacheFilename;

$applicationContext = Environment::getContext();

// exit if a precompiled version already exists
if ((file_exists($outputFilename)) && (!ApplicationContext::isDevelopmentModeActive() && (!$this->config['enableDebugMode']))) {
if ((file_exists($outputFilename)) && (!$applicationContext->isDevelopment() && (!$this->config['enableDebugMode']))) {
return $outputFilename;
}

//write intermediate file, if the source has been changed, the rest is done by the cache management
if (@filemtime($outputFilename) < @filemtime($inputFilename) || $this->_checkIfCompileNeeded($inputFilename) || ApplicationContext::isDevelopmentModeActive()) {
if (@filemtime($outputFilename) < @filemtime($inputFilename) || $this->_checkIfCompileNeeded($inputFilename) || $applicationContext->isDevelopment()) {
file_put_contents($preparedFilename, $this->_prepareCompile(file_get_contents($inputFilename)));

$fileContent = $this->_postCompile($this->_compileFile($inputFilename, $preparedFilename, $outputFilename, $cacheFilename));
Expand Down Expand Up @@ -339,5 +342,4 @@ public function prepareEnvironment($fname)
}
return true;
}

}
82 changes: 0 additions & 82 deletions Classes/Utilities/ApplicationContext.php

This file was deleted.

2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'CGLcompliance_note' => '',
'constraints' => [
'depends' => [
'typo3' => '9.5.00-10.4.99',
'typo3' => '9.5.00-11.5.99',
],
'conflicts' => [
],
Expand Down
2 changes: 1 addition & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author Kay Strobach
*/
if (!defined('TYPO3_MODE')) {
if (!defined('TYPO3')) {
die('Access denied.');
}
//if(TYPO3_MODE === 'BE') {
Expand Down
34 changes: 15 additions & 19 deletions ext_tables.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function ($extKey) {
// Add/register icons
if (TYPO3_MODE === 'BE') {
// register svg icons: identifier and filename
$iconsSvg = [
'actions-system-cache-clear-dyncss' => 'actions-system-cache-clear-dyncss.svg'
];
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
foreach ($iconsSvg as $identifier => $path) {
$iconRegistry->registerIcon(
$identifier,
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
['source' => 'EXT:' . $extKey . '/Resources/Public/Icons/' . $path]
);
}
defined('TYPO3') || die('Access denied.');
call_user_func(function() {
// Add/register icons
// register svg icons: identifier and filename
$iconsSvg = [
'actions-system-cache-clear-dyncss' => 'actions-system-cache-clear-dyncss.svg'
];
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
foreach ($iconsSvg as $identifier => $path) {
$iconRegistry->registerIcon(
$identifier,
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
['source' => 'EXT:dyncss/Resources/Public/Icons/' . $path]
);
}
},
'dyncss'
}
);