[MERGE] Branch 'master' of github_atticmedia:cjel/typo3-templates_aide
This commit is contained in:
commit
85af17b979
689
Classes/Controller/ActionController.php
Normal file
689
Classes/Controller/ActionController.php
Normal file
@ -0,0 +1,689 @@
|
||||
<?php
|
||||
namespace Cjel\TemplatesAide\Controller;
|
||||
|
||||
/***
|
||||
*
|
||||
* This file is part of the "Templates Aide" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* (c) 2018 Philipp Dieter <philippdieter@attic-media.net>
|
||||
*
|
||||
***/
|
||||
|
||||
use \Opis\JsonSchema\{
|
||||
Validator, ValidationResult, ValidationError, Schema
|
||||
};
|
||||
use TYPO3\CMS\Core\Cache\CacheManager;
|
||||
use TYPO3\CMS\Core\Log\LogManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController as BaseController;
|
||||
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
||||
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
|
||||
use TYPO3\CMS\Extbase\Property\PropertyMapper;
|
||||
use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder;
|
||||
use TYPO3\CMS\Extbase\Service\ExtensionService;
|
||||
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
|
||||
|
||||
class ActionController extends BaseController
|
||||
{
|
||||
|
||||
/*
|
||||
* page type
|
||||
*/
|
||||
protected $pageType = null;
|
||||
|
||||
/*
|
||||
* content object uid
|
||||
*/
|
||||
protected $contentObjectUid = null;
|
||||
|
||||
/*
|
||||
* cacheManager
|
||||
*/
|
||||
protected $cacheManager = null;
|
||||
|
||||
/*
|
||||
* cache
|
||||
*/
|
||||
protected $cache = null;
|
||||
|
||||
/**
|
||||
* data mapper
|
||||
*/
|
||||
protected $dataMapper = null;
|
||||
|
||||
/*
|
||||
* logManager
|
||||
*/
|
||||
protected $logManager = null;
|
||||
|
||||
/*
|
||||
* logger
|
||||
*/
|
||||
protected $importLogger = null;
|
||||
|
||||
/*
|
||||
* logger
|
||||
*/
|
||||
protected $generalLogger = null;
|
||||
|
||||
/**
|
||||
* request body
|
||||
* will only be set if page request action is post
|
||||
*/
|
||||
protected $requestBody = null;
|
||||
|
||||
/**
|
||||
* page type for ajax requests
|
||||
*/
|
||||
protected $ajaxPageType = 5000;
|
||||
|
||||
/**
|
||||
* response stus
|
||||
*/
|
||||
protected $responseStatus = 200;
|
||||
|
||||
/**
|
||||
* component mode, used in frontend
|
||||
*/
|
||||
protected $componentMode = 'default';
|
||||
|
||||
/**
|
||||
* redirect url
|
||||
*/
|
||||
protected $redirect = null;
|
||||
|
||||
/**
|
||||
* is valid
|
||||
*/
|
||||
protected $isValid = true;
|
||||
|
||||
/**
|
||||
* errors
|
||||
*/
|
||||
protected $errors = [];
|
||||
|
||||
/**
|
||||
* errors labels
|
||||
*/
|
||||
protected $errorLabels = [];
|
||||
|
||||
/**
|
||||
* ajaxEnv
|
||||
*/
|
||||
protected $ajaxEnv = [];
|
||||
|
||||
/**
|
||||
* @var \TYPO3\CMS\Extbase\Service\ExtensionService
|
||||
*/
|
||||
protected $extensionService;
|
||||
|
||||
/**
|
||||
* uribuilder
|
||||
*/
|
||||
protected $uriBuilder = null;
|
||||
|
||||
/**
|
||||
* propertyMappginConfigrtationBuolder
|
||||
*/
|
||||
protected $propertyMapperConfigurationBuilder;
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
|
||||
*/
|
||||
public function injectExtensionService(ExtensionService $extensionService)
|
||||
{
|
||||
$this->extensionService = $extensionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* propertyMapper
|
||||
*
|
||||
* @var PropertyMapper
|
||||
*/
|
||||
protected $propertyMapper;
|
||||
|
||||
/**
|
||||
* @param
|
||||
*/
|
||||
public function injectPropertyMapper(
|
||||
PropertyMapper $propertyMapper
|
||||
) {
|
||||
$this->propertyMapper = $propertyMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* propertyMappingConfigurationBuilder
|
||||
*
|
||||
* @var PropertyMappingConfigurationBuilder
|
||||
*/
|
||||
protected $propertyMappingConfigurationBuilder;
|
||||
|
||||
/**
|
||||
* @param
|
||||
*/
|
||||
public function injectPropertyMappingConfigurationBuilder(
|
||||
PropertyMappingConfigurationBuilder $propertyMappingConfigurationBuilder
|
||||
) {
|
||||
$this->propertyMappingConfigurationBuilder
|
||||
= $propertyMappingConfigurationBuilder;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initializeAction()
|
||||
{
|
||||
$this->pageType = GeneralUtility::_GP('type');
|
||||
if (!is_numeric($this->pageType)) {
|
||||
$this->pageType = 0;
|
||||
}
|
||||
if ($this->request->getMethod() == 'POST') {
|
||||
$this->requestBody = json_decode(
|
||||
file_get_contents('php://input')
|
||||
);
|
||||
}
|
||||
$this->contentObjectUid =
|
||||
$this->configurationManager->getContentObject()->data['uid'];
|
||||
$this->cacheManager = $this->objectManager->get(
|
||||
CacheManager::class
|
||||
);
|
||||
//$this->cache = $this->cacheManager->getCache(
|
||||
// 'tobereplaced' //TODO: Replaceme
|
||||
//);
|
||||
$this->logManager = $this->objectManager->get(
|
||||
LogManager::Class
|
||||
);
|
||||
$this->importLogger = $this->logManager->getLogger(
|
||||
'importLogger'
|
||||
);
|
||||
$this->generalLogger = $this->logManager->getLogger(
|
||||
__CLASS__
|
||||
);
|
||||
$this->dataMapper = $this->objectManager->get(
|
||||
DataMapper::Class
|
||||
);
|
||||
$this->arguments->addNewArgument('step', 'string', false, false);
|
||||
$this->arguments->addNewArgument('submit', 'string', false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getExtensionKey()
|
||||
{
|
||||
return $this->request->getControllerExtensionKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut function to recieve typoscript
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPluginTyposcript()
|
||||
{
|
||||
return $this->configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
|
||||
str_replace('_', '', $this->getExtensionKey),
|
||||
$this->request->getPluginName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut function to recieve typoscript
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getTyposcript()
|
||||
{
|
||||
return $this->configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut to get to know if request is submittet via post
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function isPost()
|
||||
{
|
||||
if ($this->request->getMethod() == 'POST'){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut to get to know if request is submittet via post and specific
|
||||
* step is set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function isPostStep(
|
||||
$testValue = null
|
||||
) {
|
||||
return $this->isPostAndArgumentMatches('step', $testValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function isPostSubmit(
|
||||
$testValue = null
|
||||
) {
|
||||
return $this->isPostAndArgumentMatches('submit', $testValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function isPostAndArgumentMatches(
|
||||
$argument,
|
||||
$testValue
|
||||
) {
|
||||
$value = null;
|
||||
if ($this->arguments->hasArgument($argument)){
|
||||
$value = $this->arguments->getArgument($argument)->getValue();
|
||||
}
|
||||
if (
|
||||
$this->request->getMethod() == 'POST'
|
||||
&& $value == $testValue
|
||||
){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function einTest(
|
||||
$actions = []
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function getPostSubmit()
|
||||
{
|
||||
return explode('#', $this->getPostValue('submit'))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function getPostSubmitItem()
|
||||
{
|
||||
return explode('#', $this->getPostValue('submit'))[1];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function getPostValue(
|
||||
$argument
|
||||
) {
|
||||
if ($this->arguments->hasArgument($argument)){
|
||||
return $this->arguments->getArgument($argument)->getValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function getGetValue(
|
||||
$argument
|
||||
) {
|
||||
if (GeneralUtility::_GP($argument)) {
|
||||
return GeneralUtility::_GP($argument);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut to get translation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getTranslation($key, $arguments = null)
|
||||
{
|
||||
return LocalizationUtility::translate(
|
||||
$key,
|
||||
'tobereplaced', //TODO: Replace me
|
||||
$arguments
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets error label based on field and keyword, uses predefined extensionkey
|
||||
*/
|
||||
protected function getErrorLabel($field, $keyword) {
|
||||
$path = 'error.' . $field . '.' . $keyword;
|
||||
$errorLabel = $this->getTranslation($path);
|
||||
if ($errorLabel == null) {
|
||||
return $path;
|
||||
}
|
||||
return $errorLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to add validation error manually in the controller
|
||||
*/
|
||||
protected function addValidationError($field, $keyword) {
|
||||
$this->responseStatus = [400 => 'validationError'];
|
||||
$this->errors[$field] = [
|
||||
'keyword' => $keyword,
|
||||
];
|
||||
$this->errorLabels[$field] = $this->getErrorLabel(
|
||||
$field,
|
||||
$keyword
|
||||
);
|
||||
}
|
||||
|
||||
public function arrayRemoveEmptyStrings($array)
|
||||
{
|
||||
foreach ($array as $key => &$value) {
|
||||
if (is_array($value)) {
|
||||
$value = $this->arrayRemoveEmptyStrings($value);
|
||||
} else {
|
||||
if (is_string($value) && !strlen($value)) {
|
||||
unset($array[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function arrayToObject($array) {
|
||||
if (is_array($array)) {
|
||||
return (object) array_map([__CLASS__, __METHOD__], $array);
|
||||
} else {
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate objects
|
||||
*
|
||||
* @param $input
|
||||
* @param schema
|
||||
* @return void
|
||||
*/
|
||||
protected function validateInput($input, $schema)
|
||||
{
|
||||
$validator = new Validator();
|
||||
$input = $this->arrayRemoveEmptyStrings($input);
|
||||
//@todo make optional when usiing rest api
|
||||
//array_walk_recursive(
|
||||
// $input,
|
||||
// function (&$value) {
|
||||
// if (filter_var($value, FILTER_VALIDATE_INT)) {
|
||||
// $value = (int)$value;
|
||||
// }
|
||||
// }
|
||||
//);
|
||||
$input = $this->arrayToObject($input);
|
||||
$validationResult = $validator->dataValidation(
|
||||
$input,
|
||||
json_encode($schema),
|
||||
-1
|
||||
);
|
||||
if (!$validationResult->isValid()) {
|
||||
$this->isValid = false;
|
||||
$this->responseStatus = [400 => 'validationError'];
|
||||
foreach ($validationResult->getErrors() as $error){
|
||||
$errorLabel = null;
|
||||
$field = implode('.', $error->dataPointer());
|
||||
if ($error->keyword() == 'required') {
|
||||
$tmp = $error->dataPointer();
|
||||
array_push($tmp, $error->keywordArgs()['missing']);
|
||||
$field = implode('.', $tmp);
|
||||
}
|
||||
if ($error->keyword() == 'additionalProperties') {
|
||||
continue;
|
||||
}
|
||||
$this->errors[$field] = [
|
||||
'keyword' => $error->keyword(),
|
||||
'details' => $error->keywordArgs()
|
||||
];
|
||||
if ($error->keyword() != 'required') {
|
||||
$errorLabel = $this->getTranslation(
|
||||
'error.' . $field . '.' . $error->keyword()
|
||||
);
|
||||
//if ($errorLabel == null) {
|
||||
// $errorLabel = $this->getTranslation(
|
||||
// 'error.' . $field . '.required'
|
||||
// );
|
||||
//}
|
||||
if ($errorLabel == null) {
|
||||
$errorLabel = 'error.'
|
||||
. $field
|
||||
. '.'
|
||||
. $error->keyword();
|
||||
}
|
||||
$this->errorLabels[$field] = $errorLabel;
|
||||
} else {
|
||||
$errorLabel = $this->getTranslation(
|
||||
'error.' . $field . '.required'
|
||||
);
|
||||
if ($errorLabel == null) {
|
||||
$errorLabel = 'error.'
|
||||
. $field
|
||||
. '.'
|
||||
. $error->keyword();
|
||||
}
|
||||
$this->errorLabels[$field] = $errorLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $validationResult->isValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns plugin namespace to build js post request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPluginNamespace()
|
||||
{
|
||||
$extensionName = $this->request->getControllerExtensionName();
|
||||
$pluginName = $this->request->getPluginName();
|
||||
return $this->extensionService->getPluginNamespace(
|
||||
$extensionName,
|
||||
$pluginName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets vars which are needed by the ajax requests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setAjaxEnv($object = null)
|
||||
{
|
||||
if ($object == null) {
|
||||
$object = $this->arguments->getArgumentNames()[0];
|
||||
}
|
||||
$uri = $this->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setCreateAbsoluteUri(true)
|
||||
->setTargetPageType($this->ajaxPageType)
|
||||
->setArguments(['cid' => $this->contentObjectUid])
|
||||
->uriFor($this->request->getControllerActionName());
|
||||
$this->ajaxEnv = [
|
||||
'uri' => $uri,
|
||||
'object' => $object,
|
||||
'namespace' => $this->getPluginNamespace(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The hash service class to use
|
||||
*
|
||||
* @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService
|
||||
*/
|
||||
protected $hashService;
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService
|
||||
*/
|
||||
public function injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
|
||||
{
|
||||
$this->hashService = $hashService;
|
||||
}
|
||||
|
||||
/**
|
||||
* get property mapper config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPropertyMappingConfiguration($attribute)
|
||||
{
|
||||
$propertyMappingConfiguration = $this
|
||||
->propertyMappingConfigurationBuilder->build();
|
||||
$this->initializePropertyMappingConfigurationFromRequest(
|
||||
$this->request,
|
||||
$propertyMappingConfiguration,
|
||||
$attribute
|
||||
);
|
||||
return $propertyMappingConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the property mapping configuration in $controllerArguments if
|
||||
* the trusted properties are set inside the request.
|
||||
*
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Request $request
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function initializePropertyMappingConfigurationFromRequest(\TYPO3\CMS\Extbase\Mvc\Request $request, $propertyMappingConfiguration, $propertyNameTest)
|
||||
{
|
||||
$trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
|
||||
if (!is_string($trustedPropertiesToken)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
|
||||
} catch (InvalidHashException | InvalidArgumentForHashGenerationException $e) {
|
||||
throw new BadRequestException('The HMAC of the form could not be validated.', 1581862822);
|
||||
}
|
||||
$trustedProperties = unserialize($serializedTrustedProperties, ['allowed_classes' => false]);
|
||||
foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
|
||||
|
||||
//if (!$controllerArguments->hasArgument($propertyName)) {
|
||||
// continue;
|
||||
//}
|
||||
if ($propertyName != $propertyNameTest) {
|
||||
continue;
|
||||
}
|
||||
//$propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
|
||||
$this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the passed $propertyMappingConfiguration according to the $propertyConfiguration which
|
||||
* has been generated by Fluid. In detail, if the $propertyConfiguration contains
|
||||
* an __identity field, we allow modification of objects; else we allow creation.
|
||||
*
|
||||
* All other properties are specified as allowed properties.
|
||||
*
|
||||
* @param array $propertyConfiguration
|
||||
* @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration
|
||||
*/
|
||||
protected function modifyPropertyMappingConfiguration($propertyConfiguration, \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration)
|
||||
{
|
||||
if (!is_array($propertyConfiguration)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($propertyConfiguration['__identity'])) {
|
||||
$propertyMappingConfiguration->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
|
||||
unset($propertyConfiguration['__identity']);
|
||||
} else {
|
||||
$propertyMappingConfiguration->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
|
||||
}
|
||||
|
||||
foreach ($propertyConfiguration as $innerKey => $innerValue) {
|
||||
if (is_array($innerValue)) {
|
||||
$this->modifyPropertyMappingConfiguration($innerValue, $propertyMappingConfiguration->forProperty($innerKey));
|
||||
}
|
||||
$propertyMappingConfiguration->allowProperties($innerKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return function, checks for page type and decides
|
||||
*
|
||||
* @param array $result
|
||||
* @return void
|
||||
*/
|
||||
protected function returnFunction($result = [], $errorStatus = null)
|
||||
{
|
||||
$this->setAjaxEnv();
|
||||
if ($result == null) {
|
||||
$result = [];
|
||||
}
|
||||
if (!empty($this->errors)) {
|
||||
$result = array_merge(
|
||||
$result,
|
||||
['errors' => $this->errors]
|
||||
);
|
||||
}
|
||||
if (!empty($this->errorLabels)) {
|
||||
$result = array_merge(
|
||||
$result,
|
||||
['errorLabels' => $this->errorLabels]
|
||||
);
|
||||
}
|
||||
if (is_array($this->responseStatus)) {
|
||||
$result = array_merge(
|
||||
$result,
|
||||
['errorType' => reset($this->responseStatus)]
|
||||
);
|
||||
}
|
||||
if ($this->pageType) {
|
||||
if (is_array($this->responseStatus)) {
|
||||
$this->response->setStatus(
|
||||
array_key_first($this->responseStatus)
|
||||
);
|
||||
} else {
|
||||
$this->response->setStatus($this->responseStatus);
|
||||
}
|
||||
if ($this->pageType == $this->ajaxPageType) {
|
||||
$GLOBALS['TSFE']->setContentType('application/json');
|
||||
}
|
||||
unset($result['data']);
|
||||
if ($this->redirect) {
|
||||
$result['redirect'] = $this->redirect;
|
||||
}
|
||||
return json_encode($result);
|
||||
}
|
||||
$result = array_merge(
|
||||
$result,
|
||||
['cid' => $this->contentObjectUid],
|
||||
['isValid' => $this->isValid],
|
||||
['componentMode' => $this->componentMode]
|
||||
);
|
||||
if (!empty($this->ajaxEnv)) {
|
||||
$result = array_merge(
|
||||
$result,
|
||||
['ajaxEnv' => $this->ajaxEnv]
|
||||
);
|
||||
}
|
||||
$this->view->assignMultiple($result);
|
||||
}
|
||||
|
||||
}
|
88
Classes/Property/TypeConverter/Double2Converter.php
Normal file
88
Classes/Property/TypeConverter/Double2Converter.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
namespace Cjel\TemplatesAide\Property\TypeConverter;
|
||||
|
||||
/***
|
||||
*
|
||||
* This file is part of the "Templates Aide" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* (c) 2020 Philipp Dieter <philippdieter@attic-media.net>
|
||||
*
|
||||
***/
|
||||
|
||||
use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface;
|
||||
use TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter;
|
||||
|
||||
/**
|
||||
* Converter which transforms arrays to arrays.
|
||||
*/
|
||||
class Double2Converter extends AbstractTypeConverter
|
||||
{
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $sourceTypes = ['integer', 'string'];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $targetType = 'double2';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 10;
|
||||
|
||||
/**
|
||||
* @param mixed $source
|
||||
* @param string $targetType
|
||||
* @return bool
|
||||
* @internal only to be used within Extbase, not part of TYPO3 Core API.
|
||||
*/
|
||||
public function canConvertFrom($source, $targetType)
|
||||
{
|
||||
return is_string($source) ||is_integer($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from
|
||||
* TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval
|
||||
*
|
||||
* @param string|array $source
|
||||
* @param string $targetType
|
||||
* @param array $convertedChildProperties
|
||||
* @param PropertyMappingConfigurationInterface $configuration
|
||||
* @return array
|
||||
*/
|
||||
public function convertFrom(
|
||||
$source,
|
||||
$targetType,
|
||||
array $convertedChildProperties = [],
|
||||
PropertyMappingConfigurationInterface $configuration = null
|
||||
) {
|
||||
$value = preg_replace('/[^0-9,\\.-]/', '', $source);
|
||||
$negative = $value[0] === '-';
|
||||
$value = strtr($value, [',' => '.', '-' => '']);
|
||||
if (strpos($value, '.') === false) {
|
||||
$value .= '.0';
|
||||
}
|
||||
$valueArray = explode('.', $value);
|
||||
$dec = array_pop($valueArray);
|
||||
$value = implode('', $valueArray) . '.' . $dec;
|
||||
if ($negative) {
|
||||
$value *= -1;
|
||||
}
|
||||
$value = number_format($value, 2, '.', '');
|
||||
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
|
||||
// $source, null, 3
|
||||
//);
|
||||
//if (is_string($source)) {
|
||||
// if ($source === '') {
|
||||
// $source = [];
|
||||
// }
|
||||
//}
|
||||
return $value;
|
||||
}
|
||||
}
|
216
Classes/Utility/MailUtility.php
Normal file
216
Classes/Utility/MailUtility.php
Normal file
@ -0,0 +1,216 @@
|
||||
<?php
|
||||
namespace Cjel\TemplatesAide\Utility;
|
||||
|
||||
/***
|
||||
*
|
||||
* This file is part of the "Templates Aide" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* (c) 2020 Philipp Dieter <philipp.dieter@attic-media.net>
|
||||
*
|
||||
***/
|
||||
|
||||
use TYPO3\CMS\Core\Mail\MailMessage;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Extbase\Service\ImageService;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
use TYPO3\CMS\Fluid\View\TemplatePaths;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class MailUtility
|
||||
{
|
||||
/**
|
||||
* tages maildata, builds html and text mails an decides where to send them
|
||||
* allows to intercept sender for testing
|
||||
*
|
||||
* @param string $target email or group identifier
|
||||
* @param string $subject mail subject, prefixed by setting in ts
|
||||
* @param array $data content for email, gets parsed in different ways
|
||||
* @return void
|
||||
*/
|
||||
public static function sendMail(
|
||||
$target,
|
||||
$sender,
|
||||
$subject,
|
||||
$data,
|
||||
$templateNameHtml = null,
|
||||
$templateNameText = null
|
||||
) {
|
||||
if (!$templateNameHtml) {
|
||||
$templateNameHtml = 'Mails/DefaultHtml';
|
||||
}
|
||||
if (!$templateNameText) {
|
||||
$templateNameText = 'Mails/DefaultText';
|
||||
}
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$configurationManager = $objectManager->get(
|
||||
ConfigurationManagerInterface::class
|
||||
);
|
||||
$typoScript = $configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
|
||||
);
|
||||
$settings =
|
||||
(array)$typoScript['module.']['tx_templatesaide.']['settings.'];
|
||||
$settings = GeneralUtility::removeDotsFromTS($settings);
|
||||
$htmlView = $objectManager->get(StandaloneView::class);
|
||||
$htmlView->getTemplatePaths()->fillDefaultsByPackageName(
|
||||
'templates_aide'
|
||||
);
|
||||
$htmlView->setTemplate($templateNameHtml);
|
||||
$textView = $objectManager->get(StandaloneView::class);
|
||||
$textView->getTemplatePaths()->fillDefaultsByPackageName(
|
||||
'templates_aide'
|
||||
);
|
||||
$textView->setTemplate($templateNameText);
|
||||
$mail = GeneralUtility::makeInstance(MailMessage::class);
|
||||
$mail->setFrom($sender);
|
||||
$mail->setSubject($subject);
|
||||
$bodydataText = [];
|
||||
$bodydataHtml = [];
|
||||
foreach ($data as $row) {
|
||||
switch($row['type']) {
|
||||
case 'text':
|
||||
case 'headline':
|
||||
$htmlRow = $row;
|
||||
$htmlRow['data'] = preg_replace_callback(
|
||||
'/\[.*\]/mU',
|
||||
function($matches) {
|
||||
|
||||
foreach ($matches as $match) {
|
||||
return preg_replace_callback(
|
||||
'/\[(\S*)\s(.*)\]/mU',
|
||||
function($matchesInner) {
|
||||
return '<a href="'
|
||||
. $matchesInner[1]
|
||||
. '">'
|
||||
. $matchesInner[2]
|
||||
. '</a>';
|
||||
},
|
||||
$match
|
||||
);
|
||||
}
|
||||
},
|
||||
$htmlRow['data']
|
||||
);
|
||||
$textRow = $row;
|
||||
$textRow['data'] = preg_replace_callback(
|
||||
'/\[.*\]/mU',
|
||||
function($matches) {
|
||||
foreach ($matches as $match) {
|
||||
return preg_replace_callback(
|
||||
'/\[(\S*)\s(.*)\]/mU',
|
||||
function($matchesInner) {
|
||||
return $matchesInner[2]
|
||||
. ': '
|
||||
. $matchesInner[1];
|
||||
},
|
||||
$match
|
||||
);
|
||||
}
|
||||
},
|
||||
$textRow['data']
|
||||
);
|
||||
$bodydataText[] = $textRow;
|
||||
$bodydataHtml[] = $htmlRow;
|
||||
break;
|
||||
case 'button':
|
||||
case 'buttons':
|
||||
$htmlRow = $row;
|
||||
//$htmlRow['targets'] = preg_replace_callback(
|
||||
// '/\[.*\]/mU',
|
||||
// function($matches) {
|
||||
// foreach ($matches as $match) {
|
||||
// return preg_replace_callback(
|
||||
// '/\[(\S*)\s(.*)\]/mU',
|
||||
// function($matchesInner) {
|
||||
// return $matchesInner;
|
||||
// //return '<a href="'
|
||||
// // . $matchesInner[1]
|
||||
// // . '">'
|
||||
// // . $matchesInner[2]
|
||||
// // . '</a>';
|
||||
// },
|
||||
// $match
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// $htmlRow['targets']
|
||||
//);
|
||||
$textRow = $row;
|
||||
//$textRow['targets'] = preg_replace_callback(
|
||||
// '/\[.*\]/mU',
|
||||
// function($matches) {
|
||||
// foreach ($matches as $match) {
|
||||
// return preg_replace_callback(
|
||||
// '/\[(\S*)\s(.*)\]/mU',
|
||||
// function($matchesInner) {
|
||||
// return $matchesInner;
|
||||
// //return $matchesInner[2]
|
||||
// // . ': '
|
||||
// // . $matchesInner[1];
|
||||
// },
|
||||
// $match
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// $textRow['targets']
|
||||
//);
|
||||
$bodydataText[] = $textRow;
|
||||
$bodydataHtml[] = $htmlRow;
|
||||
break;
|
||||
case 'attachmentBase64':
|
||||
$attachmentdata = explode(',', $row['data']);
|
||||
preg_match('/\w*:(.*);\w*/', $attachmentdata[0], $matches);
|
||||
$mimetype = $matches[1];
|
||||
preg_match('/\w*\/(.*);\w*/', $attachmentdata[0], $matches);
|
||||
$fileextension = $matches[1];
|
||||
$mail->attach(new \Swift_Attachment(
|
||||
base64_decode($attachmentdata[1]),
|
||||
'attachment.' . $fileextension,
|
||||
$mimetype
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$textView->assign('content', $bodydataText);
|
||||
$htmlView->assign('content', $bodydataHtml);
|
||||
$domain = $settings['mailDomain'];
|
||||
$htmlView->assign('domain', $domain);
|
||||
$textBody = $textView->render();
|
||||
$htmlBody = $htmlView->render();
|
||||
$mail->setBody($textBody);
|
||||
$mail->addPart($htmlBody, 'text/html');
|
||||
$recipients = explode(
|
||||
',',
|
||||
$target
|
||||
);
|
||||
if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['intercept_to']) {
|
||||
$subjectOrig = $mail->getSubject();
|
||||
$recipientsIntercecpted = explode(
|
||||
',',
|
||||
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['intercept_to']
|
||||
);
|
||||
foreach ($recipientsIntercecpted as $recipientIntercepted) {
|
||||
foreach ($recipients as $recipient) {
|
||||
$mail->setSubject(
|
||||
$subjectOrig . ' [ORIG-TO: ' . trim($recipient) . ']'
|
||||
);
|
||||
$mail->setTo(trim($recipientIntercepted));
|
||||
$mail->send();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($recipients as $recipient) {
|
||||
$mail->setTo(trim($recipient));
|
||||
$mail->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
Classes/Utility/RandomStringUtility.php
Normal file
32
Classes/Utility/RandomStringUtility.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Cjel\TemplatesAide\Utility;
|
||||
|
||||
/***
|
||||
*
|
||||
* This file is part of the "" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* (c) 2019 Philipp Dieter <philipp@glanzstueck.agency>, Glanzstück GmbH
|
||||
*
|
||||
***/
|
||||
|
||||
class RandomStringUtility
|
||||
{
|
||||
public static function getToken(
|
||||
int $length = 64,
|
||||
string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
): string {
|
||||
if ($length < 1) {
|
||||
throw new \RangeException("Length must be a positive integer");
|
||||
}
|
||||
$pieces = [];
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$pieces []= $keyspace[random_int(0, $max)];
|
||||
}
|
||||
return implode('', $pieces);
|
||||
}
|
||||
|
||||
}
|
22
Resources/Private/Language/de.locallang.xlf
Normal file
22
Resources/Private/Language/de.locallang.xlf
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<xliff version="1.0">
|
||||
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2020-07-16T21:32:04Z">
|
||||
<header>
|
||||
<generator>LFEditor</generator>
|
||||
</header>
|
||||
<body>
|
||||
<trans-unit id="default" approved="yes">
|
||||
<source><![CDATA[Default]]></source>
|
||||
<target><![CDATA[Standard]]></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="homepage" approved="yes">
|
||||
<source><![CDATA[Homepage]]></source>
|
||||
<target><![CDATA[Startseite]]></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="subpage" approved="yes">
|
||||
<source><![CDATA[Subpage]]></source>
|
||||
<target><![CDATA[Unterseite]]></target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
@ -1,10 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<xliff version="1.0">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2020-04-26T22:03:44Z" product-name="templates_aide">
|
||||
<header/>
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2020-07-16T21:32:04Z">
|
||||
<header>
|
||||
<generator>LFEditor</generator>
|
||||
</header>
|
||||
<body>
|
||||
<trans-unit id="default">
|
||||
<source><![CDATA[Default]]></source>
|
||||
</trans-unit>
|
||||
<trans-unit id="homepage">
|
||||
<source><![CDATA[Homepage]]></source>
|
||||
</trans-unit>
|
||||
<trans-unit id="subpage">
|
||||
<source><![CDATA[Subpage]]></source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_templatesaide_domain_model_dummy">
|
||||
<source>Dummy</source>
|
||||
<source><![CDATA[Dummy]]></source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
|
1
Resources/Private/PageTSConfig/default.tsconfig
Normal file
1
Resources/Private/PageTSConfig/default.tsconfig
Normal file
@ -0,0 +1 @@
|
||||
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:templates_aide/Resources/Private/PageTSConfig/lib/layout.tsconfig">
|
29
Resources/Private/PageTSConfig/lib/layout.tsconfig
Normal file
29
Resources/Private/PageTSConfig/lib/layout.tsconfig
Normal file
@ -0,0 +1,29 @@
|
||||
mod {
|
||||
web_layout {
|
||||
BackendLayouts {
|
||||
default {
|
||||
title = LLL:EXT:templates_aide/Resources/Private/Language/locallang.xlf:default
|
||||
config {
|
||||
backend_layout {
|
||||
colCount = 1
|
||||
rowCount = 1
|
||||
rows {
|
||||
1 {
|
||||
columns {
|
||||
1 {
|
||||
name = LLL:EXT:templates_aide/Resources/Private/Language/locallang.xlf:default
|
||||
colPos = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
homepage < .default
|
||||
homepage.title = LLL:EXT:templates_aide/Resources/Private/Language/locallang.xlf:homepage
|
||||
subpage < .default
|
||||
subpage.title = LLL:EXT:templates_aide/Resources/Private/Language/locallang.xlf:subpage
|
||||
}
|
||||
}
|
||||
}
|
66
Resources/Private/Partials/Mails/DefaultHtml.html
Normal file
66
Resources/Private/Partials/Mails/DefaultHtml.html
Normal file
@ -0,0 +1,66 @@
|
||||
<f:for each="{content}" as="row" key="rowKey" iteration="rowI" >
|
||||
<v:condition.type.isArray value="{row.data}">
|
||||
<f:then>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<f:if condition="{row.type} == 'headline' || {row.type} == 'text'">
|
||||
<!--[if mso | IE]>
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:640px;" width="640" >
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:640px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:20px;text-align:center;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td class="" style="vertical-align:top;width:600px;" >
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="vertical-align:top;padding:0;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style width="100%">
|
||||
<tr>
|
||||
<td align="left" style="font-size:0px;padding:0;word-break:break-word;">
|
||||
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:1;text-align:left;color:#000000;">
|
||||
<f:if condition="{row.type} == 'headline'">
|
||||
<f:then>
|
||||
<h2>{row.data -> f:format.nl2br() -> f:format.raw()}</h2>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<p>{row.data -> f:format.nl2br() -> f:format.raw()}</p>
|
||||
</f:else>
|
||||
</f:if>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</f:if>
|
||||
</f:else>
|
||||
</v:condition.type.isArray>
|
||||
</f:for>
|
394
Resources/Private/Templates/Mails/DefaultHtml.html
Normal file
394
Resources/Private/Templates/Mails/DefaultHtml.html
Normal file
@ -0,0 +1,394 @@
|
||||
|
||||
<!doctype html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
||||
<head>
|
||||
<title>
|
||||
</title>
|
||||
<!--[if !mso]><!-- -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<!--<![endif]-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type="text/css">
|
||||
#outlook a { padding:0; }
|
||||
.ReadMsgBody { width:100%; }
|
||||
.ExternalClass { width:100%; }
|
||||
.ExternalClass * { line-height:100%; }
|
||||
body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }
|
||||
table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }
|
||||
img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }
|
||||
p { display:block;margin:13px 0; }
|
||||
</style>
|
||||
<!--[if !mso]><!-->
|
||||
<style type="text/css">
|
||||
@media only screen and (max-width:480px) {
|
||||
@-ms-viewport { width:320px; }
|
||||
@viewport { width:320px; }
|
||||
}
|
||||
</style>
|
||||
<!--<![endif]-->
|
||||
<!--[if mso]>
|
||||
<xml>
|
||||
<o:OfficeDocumentSettings>
|
||||
<o:AllowPNG/>
|
||||
<o:PixelsPerInch>96</o:PixelsPerInch>
|
||||
</o:OfficeDocumentSettings>
|
||||
</xml>
|
||||
<![endif]-->
|
||||
<!--[if lte mso 11]>
|
||||
<style type="text/css">
|
||||
.outlook-group-fix { width:100% !important; }
|
||||
</style>
|
||||
<![endif]-->
|
||||
<style type="text/css">
|
||||
@media only screen and (min-width:480px) {
|
||||
.mj-column-per-100 { width:100% !important; max-width: 100%; }
|
||||
.mj-column-per-50 { width:50% !important; max-width: 50%; }
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
@media only screen and (max-width:480px) {
|
||||
table.full-width-mobile { width: 100% !important; }
|
||||
td.full-width-mobile { width: auto !important; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: #e0e0dc;">
|
||||
<div style="">
|
||||
<!--[if mso | IE]>
|
||||
<table
|
||||
align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
|
||||
>
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;Margin:0px auto;max-width:600px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:0px 0 20px;padding-bottom:0;text-align:center;vertical-align:top;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:600px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
<td align="center" style="font-size:0px;padding:0px 0px 10px;word-break:break-word;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:600px;">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<f:for
|
||||
each="{content}"
|
||||
as="row"
|
||||
key="rowKey"
|
||||
iteration="rowI"
|
||||
>
|
||||
<v:condition.type.isArray value="{row.data}">
|
||||
<f:then>
|
||||
<table
|
||||
align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
|
||||
>
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;Margin:0px auto;max-width:600px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:2px 32px;text-align:center;vertical-align:top;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:268px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
<td align="left" style="font-size:0px;padding:2px 4px;word-break:break-word;">
|
||||
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:1;text-align:left;color:#000000;">
|
||||
<div>{row.data.0 -> f:format.nl2br() -> f:format.raw()}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:268px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
<td align="left" style="font-size:0px;padding:2px 4px;word-break:break-word;">
|
||||
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:1;text-align:left;color:#000000;">
|
||||
<div>{row.data.1 -> f:format.nl2br() -> f:format.raw()}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<f:if condition="{row.type} == 'headline' || {row.type} == 'text'">
|
||||
<table
|
||||
align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
|
||||
>
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;Margin:0px auto;max-width:600px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:0 0;padding-top:0;text-align:center;vertical-align:top;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:600px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
<td align="left" style="font-size:0px;padding:0 34px;word-break:break-word;">
|
||||
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:22px;text-align:left;color:#000000;">
|
||||
<f:if condition="{row.type} == 'headline'">
|
||||
<f:then>
|
||||
<h2>{row.data -> f:format.nl2br() -> f:format.raw()}</h2>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<p>{row.data -> f:format.nl2br() -> f:format.raw()}</p>
|
||||
</f:else>
|
||||
</f:if>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</f:if>
|
||||
<f:if condition="{row.type} == 'button'">
|
||||
|
||||
<table
|
||||
align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
|
||||
>
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;Margin:0px auto;max-width:600px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:2px 32px;text-align:center;vertical-align:top;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:268px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
|
||||
<td align="center" vertical-align="middle" class="button" style="background-color: #FFFFFF; font-size: 0px; padding: 20px 10px; word-break: break-word;" bgcolor="#FFFFFF">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
|
||||
<tr>
|
||||
<td align="center" bgcolor="#4667A7" role="presentation" style="background-color: #4667A7; border: none; border-radius: 0; cursor: auto; mso-padding-alt: 0; background: #4667A7;" valign="middle">
|
||||
<a href="{row.targets.0.0}" style="display: inline-block; background: #4667A7; color: #ffffff; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 120%; margin: 0; text-decoration: none; text-transform: none; padding: 0; mso-padding-alt: 0px; border-radius: 0;" target="_blank">
|
||||
<span class="button-inner" style="padding: 15px 42px; display: block; border: 1px solid #4667A7; color: #ffffff; font-size: 14px; font-weight: bold;">{row.targets.0.1}</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</f:if>
|
||||
<f:if condition="{row.type} == 'buttons'">
|
||||
|
||||
<table
|
||||
align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
|
||||
>
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;Margin:0px auto;max-width:600px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:2px 32px;text-align:center;vertical-align:top;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:268px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
|
||||
<td align="center" vertical-align="middle" class="button" style="background-color: #FFFFFF; font-size: 0px; padding: 20px 10px; word-break: break-word;" bgcolor="#FFFFFF">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
|
||||
<tr>
|
||||
<td align="center" bgcolor="#4667A7" role="presentation" style="background-color: #4667A7; border: none; border-radius: 0; cursor: auto; mso-padding-alt: 0; background: #4667A7;" valign="middle">
|
||||
<a href="{row.targets.0.0}" style="display: inline-block; background: #4667A7; color: #ffffff; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 120%; margin: 0; text-decoration: none; text-transform: none; padding: 0; mso-padding-alt: 0px; border-radius: 0;" target="_blank">
|
||||
<span class="button-inner" style="padding: 15px 42px; display: block; border: 1px solid #4667A7; color: #ffffff; font-size: 14px; font-weight: bold;">{row.targets.0.1}</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
<td
|
||||
class="" style="vertical-align:top;width:268px;"
|
||||
>
|
||||
<![endif]-->
|
||||
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
||||
<tr>
|
||||
|
||||
<td align="center" vertical-align="middle" class="button" style="background-color: #FFFFFF; font-size: 0px; padding: 20px 10px; word-break: break-word;" bgcolor="#FFFFFF">
|
||||
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
|
||||
<tr>
|
||||
<td align="center" bgcolor="#4667A7" role="presentation" style="background-color: #4667A7; border: none; border-radius: 0; cursor: auto; mso-padding-alt: 0; background: #4667A7;" valign="middle">
|
||||
<a href="{row.targets.1.0}" style="display: inline-block; background: #4667A7; color: #ffffff; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 120%; margin: 0; text-decoration: none; text-transform: none; padding: 0; mso-padding-alt: 0px; border-radius: 0;" target="_blank">
|
||||
<span class="button-inner" style="padding: 15px 42px; display: block; border: 1px solid #4667A7; color: #ffffff; font-size: 14px; font-weight: bold;">{row.targets.1.1}</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</f:if>
|
||||
</f:else>
|
||||
</v:condition.type.isArray>
|
||||
</f:for>
|
||||
<table
|
||||
align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
|
||||
>
|
||||
<tr>
|
||||
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
||||
<![endif]-->
|
||||
<div style="background:#ffffff;background-color:#ffffff;Margin:0px auto;max-width:600px;">
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="direction:ltr;font-size:0px;padding:20px;text-align:center;vertical-align:top;">
|
||||
<!--[if mso | IE]>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso | IE]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
20
Resources/Private/Templates/Mails/DefaultText.html
Normal file
20
Resources/Private/Templates/Mails/DefaultText.html
Normal file
@ -0,0 +1,20 @@
|
||||
<v:variable.set name="br">
|
||||
</v:variable.set>
|
||||
<f:for
|
||||
each="{content}"
|
||||
as="row"
|
||||
key="rowKey"
|
||||
iteration="rowI"
|
||||
><v:format.trim>
|
||||
<v:condition.type.isArray value="{row.data}">
|
||||
<f:then>{row.data.0}: {row.data.1}</f:then>
|
||||
<f:else><f:if condition="{row.type} == 'headline' || {row.type} == 'text'"><f:if condition="{row.type} == 'headline'">
|
||||
<f:then>= {row.data} =</f:then>
|
||||
<f:else>{row.data}</f:else>
|
||||
</f:if></f:if></f:else>
|
||||
</v:condition.type.isArray>
|
||||
</v:format.trim><f:if condition="{content.{rowI.cycle}.data}">{br}<f:if condition="{v:condition.type.isArray(value='{content.{rowI.index}.data}', then: '1')} && {v:condition.type.isArray(value='{content.{rowI.cycle}.data}', then: '1')}"><f:else>{br}</f:else></f:if></f:if><f:if condition="{row.type} == 'buttons'">
|
||||
<f:then>{br}{br}{row.targets.0.1}:{br}{row.targets.0.0}{br}{br}{row.targets.1.1}:{br}{row.targets.1.0}</f:then>
|
||||
</f:if><f:if condition="{row.type} == 'button'">
|
||||
<f:then>{br}{br}{row.targets.0.1}:{br}{row.targets.0.0}</f:then>
|
||||
</f:if></f:for>
|
@ -1,18 +1,25 @@
|
||||
# legacy
|
||||
|
||||
lib.rootpid = TEXT
|
||||
lib.rootpid.data = leveluid : 0
|
||||
|
||||
lib.pidRoot = TEXT
|
||||
lib.pidRoot.data = leveluid : 0
|
||||
|
||||
lib.currentLevel = TEXT
|
||||
lib.currentLevel.data = level:1
|
||||
|
||||
lib.currentPid = TEXT
|
||||
lib.currentPid.data = TSFE:id
|
||||
|
||||
# legacy end
|
||||
|
||||
lib.pidRoot = TEXT
|
||||
lib.pidRoot.data = leveluid : 0
|
||||
|
||||
lib.pidCurrent = TEXT
|
||||
lib.pidCurrent.data = TSFE:id
|
||||
|
||||
lib.level = TEXT
|
||||
lib.level.data = level:1
|
||||
|
||||
lib.gpvar = COA
|
||||
lib.gpvar {
|
||||
stdWrap.htmlSpecialChars = 1
|
||||
|
@ -2,7 +2,19 @@ page = PAGE
|
||||
page {
|
||||
10 = FLUIDTEMPLATE
|
||||
10 {
|
||||
templateName = Base
|
||||
templateName.stdWrap {
|
||||
cObject = TEXT
|
||||
cObject {
|
||||
data = levelfield:-2,backend_layout_next_level,slide
|
||||
override.field = backend_layout
|
||||
split {
|
||||
token = pagets__
|
||||
1.current = 1
|
||||
1.wrap = |
|
||||
}
|
||||
}
|
||||
ifEmpty = Base
|
||||
}
|
||||
layoutRootPaths {
|
||||
0 = EXT:site_templates/Resources/Private/Layouts
|
||||
}
|
||||
|
@ -56,4 +56,4 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1549297828] = [
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['c'] = [];
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['c'][]
|
||||
= 'Cjel\TemplatesAide\ViewHelpers';
|
||||
= 'Cjel\TemplatesAide\ViewHelpers';
|
||||
|
@ -20,6 +20,9 @@ call_user_func(
|
||||
);
|
||||
## EXTENSION BUILDER DEFAULTS END TOKEN - Everything BEFORE this line is overwritten with the defaults of the extension builder
|
||||
|
||||
use Cjel\TemplatesAide\Property\TypeConverter\Double2Converter;
|
||||
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
|
||||
|
||||
call_user_func(
|
||||
function()
|
||||
{
|
||||
@ -37,6 +40,15 @@ call_user_func(
|
||||
'EXT:templates_aide/Resources/Public/Css/backend/production-stage';
|
||||
}
|
||||
|
||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
|
||||
'templates_aide',
|
||||
'Resources/Private/PageTSConfig/default.tsconfig',
|
||||
'Default Config'
|
||||
);
|
||||
|
||||
|
||||
ExtensionUtility::registerTypeConverter(Double2Converter::class);
|
||||
|
||||
if (TYPO3_MODE == 'BE') {
|
||||
//$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
|
||||
// \TYPO3\CMS\Core\Page\PageRenderer::class
|
||||
|
Loading…
x
Reference in New Issue
Block a user