Skip to content
Snippets Groups Projects

Release 5.0.0

Merged Georgi requested to merge release_5.0.0 into master
8 files
+ 130
19
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -36,6 +36,7 @@ use SGalinski\SgRoutes\Domain\Repository\LogRepository;
use SGalinski\SgRoutes\Domain\Repository\PageNotFoundHandlingRepository;
use SGalinski\SgRoutes\Domain\Repository\RoutehitRepository;
use SGalinski\SgRoutes\Domain\Repository\RouteRepository;
use SGalinski\SgRoutes\Service\LicenceCheckService;
use SGalinski\SgRoutes\Service\LicensingService;
use SGalinski\SgRoutes\Service\RoutingService;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
@@ -174,7 +175,6 @@ class RouteController extends ActionController {
$this->command = GeneralUtility::_GP('cmd');
$this->clipboardCommandArray = GeneralUtility::_GP('CB');
$this->initClipboard();
$this->initDemoMode();
}
/**
@@ -260,6 +260,8 @@ class RouteController extends ActionController {
FlashMessage::ERROR
);
}
$this->initDemoMode();
}
/**
@@ -595,53 +597,90 @@ class RouteController extends ActionController {
return $taskExists;
}
/**
* Initializes the demo mode
*/
protected function initDemoMode() {
$typo3Version = VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
$keyState = DemoModeService::checkKey();
$hasValidLicense = LicenceCheckService::hasValidLicense();
$isInDemoMode = DemoModeService::isInDemoMode();
if ($keyState !== DemoModeService::STATE_LICENSE_VALID && $isInDemoMode) {
if (!$hasValidLicense && $isInDemoMode) {
// - 1 because the flash message would show 00:00:00 instead of 23:59:59
$this->addFlashMessage(
LocalizationUtility::translate(
'backend.licenseKey.isInDemoMode.description', 'sg_cookie_optin', [
'backend.licenseKey.isInDemoMode.description', 'sg_routes', [
date('H:i:s', mktime(0, 0, DemoModeService::getRemainingTimeInDemoMode() - 1))
]
),
LocalizationUtility::translate('backend.licenseKey.isInDemoMode.header', 'sg_cookie_optin'),
LocalizationUtility::translate('backend.licenseKey.isInDemoMode.header', 'sg_routes'),
AbstractMessage::INFO
);
} elseif ($keyState === DemoModeService::STATE_LICENSE_INVALID) {
if ($typo3Version < 9000000) {
$description = LocalizationUtility::translate(
'backend.licenseKey.invalid.description', 'sg_cookie_optin'
'backend.licenseKey.invalid.description', 'sg_routes'
);
} else {
$description = LocalizationUtility::translate(
'backend.licenseKey.invalid.descriptionTYPO3-9', 'sg_cookie_optin'
'backend.licenseKey.invalid.descriptionTYPO3-9', 'sg_routes'
);
}
$this->addFlashMessage(
$description,
LocalizationUtility::translate('backend.licenseKey.invalid.header', 'sg_cookie_optin'),
LocalizationUtility::translate('backend.licenseKey.invalid.header', 'sg_routes'),
AbstractMessage::ERROR
);
} elseif ($keyState === DemoModeService::STATE_LICENSE_NOT_SET) {
if ($typo3Version < 9000000) {
$description = LocalizationUtility::translate(
'backend.licenseKey.notSet.description', 'sg_cookie_optin'
'backend.licenseKey.notSet.description', 'sg_routes'
);
} else {
$description = LocalizationUtility::translate(
'backend.licenseKey.notSet.descriptionTYPO3-9', 'sg_cookie_optin'
'backend.licenseKey.notSet.descriptionTYPO3-9', 'sg_routes'
);
}
$this->addFlashMessage(
$description,
LocalizationUtility::translate('backend.licenseKey.notSet.header', 'sg_cookie_optin'),
LocalizationUtility::translate('backend.licenseKey.notSet.header', 'sg_routes'),
AbstractMessage::WARNING
);
}
$this->view->assign('invalidKey', !$hasValidLicense);
$this->view->assign('showDemoButton', !$isInDemoMode && DemoModeService::isDemoModeAcceptable());
}
/**
* Add a flash message
*
* @param string $messageBody
* @param string $messageTitle
* @param int $severity
* @param bool $storeInSession
*/
public function addFlashMessage($messageBody, $messageTitle = '', $severity = AbstractMessage::OK, $storeInSession = true)
{
if (null === $this->controllerContext) {
$this->controllerContext = $this->buildControllerContext();
}
parent::addFlashMessage($messageBody, $messageTitle, $severity, $storeInSession);
}
/**
* Activates the demo mode for the given instance.
*
* @throws StopActionException
*/
public function activateDemoModeAction() {
if (DemoModeService::isInDemoMode() || !DemoModeService::isDemoModeAcceptable()) {
$this->redirect('list');
}
DemoModeService::activateDemoMode();
$this->redirect('list');
}
}
Loading