This commit is contained in:
Philipp Dieter
2022-01-05 13:40:55 +01:00
12 changed files with 161 additions and 25 deletions

View File

@@ -21,6 +21,9 @@ class ArrayUtility
* function arrayTobject
*/
public static function toObject($array) {
if ($array === []) {
return (object)$array;
}
if (is_array($array)) {
if (self::isAssoc($array)) {
return (object) array_map([__CLASS__, __METHOD__], $array);
@@ -50,7 +53,6 @@ class ArrayUtility
return $array;
}
/**
*
*/

View File

@@ -214,6 +214,17 @@ class MailUtility
},
$htmlRow['data']
);
$htmlRow['data'] = preg_replace_callback(
'/\*.*\*/mU',
function($matches) {
foreach ($matches as $match) {
return '<b>'
. substr($match, 1, -1)
. '</b>';
}
},
$htmlRow['data']
);
$textRow = $row;
$textRow['data'] = preg_replace_callback(
'/\[.*\]/mU',
@@ -222,6 +233,11 @@ class MailUtility
return preg_replace_callback(
'/\[(\S*)\s(.*)\]/mU',
function($matchesInner) {
if (
$matchesInner[2] == $matchesInner[1]
) {
return $matchesInner[1];
}
return $matchesInner[2]
. ': '
. $matchesInner[1];
@@ -314,8 +330,13 @@ class MailUtility
$htmlBody
);
}
$mail->setBody($textBody);
$mail->addPart($htmlBody, 'text/html');
if (version_compare(TYPO3_branch, '10.0', '>=')) {
$mail->html($htmlBody);
$mail->text($textBody);
} else {
$mail->setBody($textBody);
$mail->addPart($htmlBody, 'text/html');
}
$recipients = explode(
',',
$target

View File

@@ -92,6 +92,13 @@ class ObjectUtility
) {
$value = StringUtility::checkAndfixUtf8($value);
$object->_setProperty($property, $value);
} elseif (
get_class($methodType) == 'ReflectionNamedType'
&&
substr($property, -3) != 'Uid'
) {
$value = StringUtility::checkAndfixUtf8($value);
$object->_setProperty($property, $value);
} elseif (
substr($property, -3) === 'Uid'
) {

View File

@@ -58,4 +58,38 @@ class SiteConfigUtility
}
return $current;
}
/**
* Gets extension config by typoscript path
*
* @var string $path
* @return string
*/
public static function getFromExtensionByPath(
$extensionName,
$path
) {
$pathParts = explode('.', $path);
$objectManager = GeneralUtility::makeInstance(
ObjectManager::class
);
$configurationManager = $objectManager->get(
ConfigurationManagerInterface::class
);
$typoscript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
$extensionName
);
$current = &$typoscript;
foreach ($pathParts as $key) {
if (
!is_array($current)
|| !array_key_exists($key, $current)
) {
return null;
}
$current = &$current[$key];
}
return $current;
}
}

View File

@@ -71,4 +71,20 @@ class StringUtility
}
return $string;
}
public static function removeCHashIfOnlyParameter($uri) {
$parsedUri = parse_url($uri);
parse_str($parsedUri['query'], $parsedQuery);
if (
count($parsedQuery) == 1
&& array_key_exists('cHash', $parsedQuery)
) {
unset($parsedQuery['cHash']);
}
$updatedQuery = http_build_query($parsedQuery);
return $parsedUri['scheme'] . '://'
. $parsedUri['host']
. $parsedUri['path']
. ($updatedQuery ? '?' . $updatedQuery : '');
}
}

View File

@@ -14,6 +14,8 @@ namespace Cjel\TemplatesAide\Utility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Localization\LanguageService;
/**
*
@@ -88,23 +90,35 @@ class TcaUtility
*/
public static function getTranslation($key, $extensionKey)
{
if ($extensionKey) {
if (version_compare(TYPO3_branch, '10.0', '>=')) {
if (!$extensionKey) {
$extensionKey = 'site_templates';
}
return implode([
'LLL:EXT:',
$extensionKey,
'/Resources/Private/Language/locallang_db.xlf:',
$key
]);
} else {
if ($extensionKey) {
$translation = LocalizationUtility::translate(
$key,
$extensionKey
);
if ($translation) {
return $translation;
}
}
$translation = LocalizationUtility::translate(
$key,
$extensionKey
'site_templates'
);
if ($translation) {
return $translation;
}
return null;
}
$translation = LocalizationUtility::translate(
$key,
'site_templates'
);
if ($translation) {
return $translation;
}
return null;
}
/**