[MERGE] Branch 'master' of ssh://phabricator.glanzstueck.agency/source/typo3-template_aide

This commit is contained in:
Philipp Dieter 2022-05-07 02:34:12 +02:00
commit ff36e401a7
15 changed files with 489 additions and 61 deletions

View File

@ -45,7 +45,11 @@ class ArrayUtility
$value = self::removeEmptyStrings($value);
} else {
if (is_string($value) && !strlen($value)) {
if (is_array($array)) {
unset($array[$key]);
} else {
unset($array->$key);
}
}
}
}

View File

@ -0,0 +1,57 @@
<?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) 2022 Philipp Dieter
*
***/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
/**
* Holds functions to help with database interactions
*/
class DatabaseUtility
{
/**
* Mysql date format
*/
const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s';
/**
* Returns table name by model
*
* @param $model object model
* @return string table name
*/
public static function getTableNameFromModelClass($class)
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$dataMapper = $objectManager->get(DataMapper::class);
return $dataMapper->getDataMap($class)->getTableName();
}
/**
* Creates a new query builder and returns it
*
* @param $tablename string table name
* @return object queryBuilder
*/
public static function getQueryBuilderFromTableName($tableName)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($tableName)
->createQueryBuilder();
return $queryBuilder;
}
}

View File

@ -59,6 +59,18 @@ class MailUtility
$type = 'list';
$textPart = substr($textPart, 2);
}
if (substr($textPart, 0, 3) === '+< ') {
$type = 'buttonleft';
$textPart = substr($textPart, 3);
}
if (substr($textPart, 0, 3) === '+| ') {
$type = 'buttoncenter';
$textPart = substr($textPart, 3);
}
if (substr($textPart, 0, 3) === '+> ') {
$type = 'buttonright';
$textPart = substr($textPart, 3);
}
if (substr($textPart, 0, 2) === '| ') {
$type = 'table';
$textPart = substr($textPart, 2);
@ -116,6 +128,28 @@ class MailUtility
return $result;
}
/**
* Gets row from content by given type
*
* @param array $content the mail content
* @param string $type the type to search
*/
public static function extractByType($content, $type)
{
$elementPosition = array_search(
$type,
array_column($content, 'type')
);
if (!$elementPosition === false) {
return;
}
if (!array_key_exists('data', $content[$elementPosition])) {
return;
}
return $content[$elementPosition]['data'];
}
/**
* tages maildata, builds html and text mails an decides where to send them
* allows to intercept sender for testing
@ -195,6 +229,10 @@ class MailUtility
case 'headline':
case 'headline2':
case 'headline3':
case 'button':
case 'buttonleft':
case 'buttoncenter':
case 'buttonright':
$row['data'] = str_replace(
"\\\n",
'',
@ -203,16 +241,33 @@ class MailUtility
$htmlRow = $row;
$htmlRow['data'] = preg_replace_callback(
'/\[.*\]/mU',
function($matches) {
function($matches) use ($row) {
foreach ($matches as $match) {
return preg_replace_callback(
'/\[(\S*)\s(.*)\]/mU',
function($matchesInner) {
function($matchesInner) use ($row) {
switch($row['type']) {
case 'button':
case 'buttonleft':
case 'buttoncenter':
case 'buttonright':
return '<a style="display: inline-block;" href="'
. $matchesInner[1]
. '">'
. '<span style="display: inline-block; padding: 10px 15px; border-radius: 3px; background-color: red;">'
. 'Button!!!! '
. $matchesInner[2]
. '</span>'
. '</a>';
break;
default:
return '<a href="'
. $matchesInner[1]
. '">'
. $matchesInner[2]
. '</a>';
break;
}
},
$match
);
@ -257,51 +312,77 @@ class MailUtility
$bodydataText[] = $textRow;
$bodydataHtml[] = $htmlRow;
break;
case 'button':
case 'buttons':
$htmlRow = $row;
//$htmlRow['targets'] = preg_replace_callback(
//case 'button':
// $row['data'] = str_replace(
// "\\\n",
// '',
// $row['data']
// );
// $htmlRow = $row;
// $htmlRow['data'] = preg_replace_callback(
// '/\[.*\]/mU',
// function($matches) {
// foreach ($matches as $match) {
// $test = preg_replace_callback(
// '/\[(\S*)\s(.*)\]/mU',
// function($matchesInner) {
//
// return '<a href="'
// . $matchesInner[1]
// . '">'
// . $matchesInner[2]
// . '</a>';
// },
// $match
// );
// \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
// $test, null, 3, true, false
// );
// return $test;
// }
// },
// $htmlRow['data']
// );
// \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
// $htmlRow['data'], null, 3, true, false
// );
// $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',
// 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>';
// if (
// $matchesInner[2] == $matchesInner[1]
// ) {
// return $matchesInner[1];
// }
// return $matchesInner[2]
// . ': '
// . $matchesInner[1];
// },
// $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['data']
// );
// }
// },
// $textRow['targets']
//);
$bodydataText[] = $textRow;
$bodydataHtml[] = $htmlRow;
break;
// $bodydataText[] = $textRow;
// $bodydataHtml[] = $htmlRow;
// break;
case 'attachment':
$mail->attach(new \Swift_Attachment(
$row['data'][0],
@ -325,6 +406,9 @@ class MailUtility
}
$textView->assign('content', $bodydataText);
$htmlView->assign('content', $bodydataHtml);
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
// $bodydataHtml, null, 8, true, false
//);
$domain = $settings['mailDomain'];
if ($assetDomain) {
$domain = $assetDomain;

View File

@ -15,6 +15,7 @@ namespace Cjel\TemplatesAide\Utility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
/**
* Utility to work with site config
@ -35,20 +36,33 @@ class SiteConfigUtility
$objectManager = GeneralUtility::makeInstance(
ObjectManager::class
);
$typoScriptParser = GeneralUtility::makeInstance(
TypoScriptParser::class
);
$configurationManager = $objectManager->get(
ConfigurationManagerInterface::class
);
$typoscript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
$typoscript = GeneralUtility::removeDotsFromTS($typoscript);
$siteConfig = $typoscript;
if ($limitToSiteConfig) {
$siteConfig = $typoscript['config']['site'];
$siteConfig = $typoscript['config.']['site.'];
}
$current = &$siteConfig;
foreach ($pathParts as $key) {
if ($current[$key . '.']) {
$key .= '.';
}
$current = &$current[$key];
if (isset($current[0]) && $current[0] === '<') {
$searchkey = trim(substr($current, 1));
list($name, $conf) = $typoScriptParser->getVal(
$searchkey,
$typoscript
);
$current = $conf;
}
}
if (is_array($current)
&& array_key_exists('value', $current)

View File

@ -0,0 +1,64 @@
<?php
namespace Cjel\TemplatesAide\ViewHelpers;
/***
*
* 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) 2022 Philipp Dieter <philipp.dieter@attic-media.net>
*
***/
use Cjel\TemplatesAide\Utility\SiteConfigUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class SiteConfigViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* Initialize arguements
*
* @return void
*/
public function initializeArguments()
{
$this->registerArgument(
'key',
'string',
'The config key to get',
true
);
$this->registerArgument(
'siteConfig',
'bool',
'Limit the typoscript to the config.site part',
false,
true
);
}
/**
* Render tranlation
*
* @param $arguments array arguments
* @param $renderChildrenClosure Closure
* @param $renderingContext $renderChildrenClosure
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
return SiteConfigUtility::getByPath(
$arguments['key'],
$arguments['siteConfig']
);
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Cjel\TemplatesAide\ViewHelpers;
/***
*
* 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) 2022 Philipp Dieter <philipp.dieter@attic-media.net>
*
***/
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class TranslationViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* Initialize arguements
*
* @return void
*/
public function initializeArguments()
{
$this->registerArgument(
'key',
'string',
'The translation key to render',
true
);
}
/**
* Render tranlation
*
* @param $arguments array arguments
* @param $renderChildrenClosure Closure
* @param $renderingContext $renderChildrenClosure
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
return 'this.extension.translation';
}
}

View File

@ -0,0 +1,4 @@
<?php
defined('TYPO3_MODE') || die('Access denied.');
$tca = &$GLOBALS['TCA']['be_users'];

3
Makefile Normal file
View File

@ -0,0 +1,3 @@
add_upstreams:
git remote add upstream-dt git@git.datentonne.net:typo3/template_aide.git
git remote add upstream-gs ssh://vcs@phabricator.glanzstueck.agency/source/typo3-template_aide.git

View File

@ -1,6 +1,6 @@
<?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">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2022-04-28T10:23:09Z">
<header>
<generator>LFEditor</generator>
</header>
@ -9,6 +9,10 @@
<source><![CDATA[Default]]></source>
<target><![CDATA[Standard]]></target>
</trans-unit>
<trans-unit id="disableDragModal" approved="yes">
<source><![CDATA[Disable drag and drop confirmation in page tree]]></source>
<target><![CDATA[Drag & Drop-Bestätigung im Seitenbaum deaktivieren]]></target>
</trans-unit>
<trans-unit id="homepage" approved="yes">
<source><![CDATA[Homepage]]></source>
<target><![CDATA[Startseite]]></target>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2020-07-16T21:32:04Z">
<file source-language="en" datatype="plaintext" original="messages" date="2022-04-28T10:23:09Z">
<header>
<generator>LFEditor</generator>
</header>
@ -8,6 +8,9 @@
<trans-unit id="default">
<source><![CDATA[Default]]></source>
</trans-unit>
<trans-unit id="disableDragModal">
<source><![CDATA[Disable drag and drop confirmation in page tree]]></source>
</trans-unit>
<trans-unit id="homepage">
<source><![CDATA[Homepage]]></source>
</trans-unit>

View File

@ -14,7 +14,13 @@
<f:for each="{content}" as="row" key="rowKey" iteration="rowI" >
<v:condition.type.isArray value="{row.data}">
<f:else>
<f:if condition="{v:condition.string.contains(haystack: '{row.type}', needle: 'headline', then: '1')} || {row.type} == 'text'">
<f:if condition="{v:condition.string.contains(haystack: '{row.type}', needle: 'headline', then: '1')}
|| {row.type} == 'text'
|| {row.type} == 'button'
|| {row.type} == 'buttonleft'
|| {row.type} == 'buttoncenter'
|| {row.type} == 'buttonright'
">
<!--[if mso | IE]>
<table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:{width}px;" width="{width}" >
<tr>
@ -37,8 +43,19 @@
<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.4;text-align:left;color:#000000;">
<f:switch expression="{row.type}">
<f:case value="buttonright">
<f:variable name='align' value='right' />
</f:case>
<f:case value="buttoncenter">
<f:variable name='align' value='center' />
</f:case>
<f:defaultCase>
<f:variable name='align' value='left' />
</f:defaultCase>
</f:switch>
<td align="{align}" style="font-size:0px;padding:0;word-break:break-word;">
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:1.4;text-align:{align};color:#000000;">
<f:switch expression="{row.type}">
<f:case value="headline">
<h1>{row.data -> f:format.nl2br() -> f:format.raw()}</h1>
@ -49,6 +66,26 @@
<f:case value="headline3">
<h3>{row.data -> f:format.nl2br() -> f:format.raw()}</h3>
</f:case>
<f:case value="button">
<span style="display: inline-block;" class="buttonwrapper">
{row.data -> f:format.nl2br() -> f:format.raw()}
</span>
</f:case>
<f:case value="buttonleft">
<span style="display: inline-block;" class="buttonwrapper">
{row.data -> f:format.nl2br() -> f:format.raw()}
</span>
</f:case>
<f:case value="buttoncenter">
<span style="display: inline-block;" class="buttonwrapper">
{row.data -> f:format.nl2br() -> f:format.raw()}
</span>
</f:case>
<f:case value="buttonright">
<span style="display: inline-block;" class="buttonwrapper">
{row.data -> f:format.nl2br() -> f:format.raw()}
</span>
</f:case>
<f:defaultCase>
<p>{row.data -> f:format.nl2br() -> f:format.raw()}</p>
</f:defaultCase>

View File

@ -0,0 +1,37 @@
*** webroot/typo3/sysext/core/Classes/DataHandling/DataHandler.php.orig 2022-04-22 13:15:26.314780488 +0200
--- webroot/typo3/sysext/core/Classes/DataHandling/DataHandler.php 2022-04-22 13:15:39.018129312 +0200
*************** class DataHandler implements LoggerAware
*** 7431,7446 ****
}
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
$insertErrorMessage = '';
! try {
// Execute the INSERT query:
$connection->insert(
$table,
$fieldArray,
$typeArray
);
! } catch (DBALException $e) {
! $insertErrorMessage = $e->getPrevious()->getMessage();
! }
// If succees, do...:
if ($insertErrorMessage === '') {
// Set mapping for NEW... -> real uid:
--- 7431,7446 ----
}
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
$insertErrorMessage = '';
! //try {
// Execute the INSERT query:
$connection->insert(
$table,
$fieldArray,
$typeArray
);
! //} catch (DBALException $e) {
! // $insertErrorMessage = $e->getPrevious()->getMessage();
! //}
// If succees, do...:
if ($insertErrorMessage === '') {
// Set mapping for NEW... -> real uid:

View File

@ -0,0 +1,12 @@
--- webroot/typo3/sysext/impexp/Classes/Import.php 2022-04-22 12:43:09.439221153 +0200
+++ webroot/typo3/sysext/impexp/Classes/Import.php 2022-04-22 12:43:27.169242298 +0200
@@ -446,7 +446,8 @@
}
if ($newFile->getSha1() !== $fileRecord['sha1']) {
- $this->error('Error: The hash of the written file is not identical to the import data! File could be corrupted! File: "' . $fileRecord['identifier'] . '" with storage uid "' . $fileRecord['storage'] . '"');
+ print('Error: The hash of the written file is not identical to the import data! File could be corrupted! File: "' . $fileRecord['identifier'] . '" with storage uid "' . $fileRecord['storage'] . '"');
+ print(PHP_EOL);
}
}

View File

@ -0,0 +1,41 @@
--- a/Resources/Public/JavaScript/SvgTree.js 2022-04-28 12:32:01.961189044 +0200
+++ b/Resources/Public/JavaScript/SvgTree.js 2022-04-28 12:32:06.047858227 +0200
@@ -37,6 +37,7 @@
showCheckboxes: false,
showIcons: false,
allowRecursiveDelete: false,
+ disableDragModal: false,
marginTop: 15,
nodeHeight: 20,
indentWidth: 16,
--- a/Resources/Public/JavaScript/PageTree/PageTreeDragDrop.js 2022-04-28 11:43:41.046705421 +0200
+++ b/Resources/Public/JavaScript/PageTree/PageTreeDragDrop.js 2022-04-28 12:30:40.741138721 +0200
@@ -275,6 +275,10 @@
var modalText = options.position === 'in' ? TYPO3.lang['mess.move_into'] : TYPO3.lang['mess.move_after'];
modalText = modalText.replace('%s', options.node.name).replace('%s', options.target.name);
+ if (tree.settings.disableDragModal) {
+ options.command = 'move';
+ tree.sendChangeCommand(options);
+ } else {
Modal.confirm(
TYPO3.lang.move_page,
modalText,
@@ -307,6 +311,7 @@
Modal.dismiss();
});
+ }
} else if (tree.nodeIsOverDelete) {
var options = _this.changeNodePosition({droppedNode: droppedNode, command: 'delete'});
if (tree.settings.displayDeleteConfirmation) {
--- a/Classes/Controller/Page/TreeController.php 2022-04-28 13:00:20.025466105 +0200
+++ b/Classes/Controller/Page/TreeController.php 2022-04-28 13:00:22.312133921 +0200
@@ -155,6 +155,7 @@
'doktypes' => $this->getDokTypes(),
'displayDeleteConfirmation' => $this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE),
'temporaryMountPoint' => $this->getMountPointPath((int)($this->getBackendUser()->uc['pageTree_temporaryMountPoint'] ?? 0)),
+ 'disableDragModal' => !empty($this->getBackendUser()->uc['disableDragModal'])
];
return new JsonResponse($configuration);

View File

@ -40,7 +40,7 @@ call_user_func(
'EXT:templates_aide/Resources/Public/Css/backend/production-stage';
}
$GLOBALS['TBE_STYLES']['skins']['backend']['stylesheetDirectories']['default'] =
$GLOBALS['TBE_STYLES']['skins']['backend']['stylesheetDirectories']['templates_aide_default'] =
'EXT:templates_aide/Resources/Public/Css/backend/default';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
@ -65,3 +65,14 @@ call_user_func(
}
);
$GLOBALS['TYPO3_USER_SETTINGS']['columns']['disableDragModal'] = [
'type' => 'check',
'label' => 'LLL:EXT:templates_aide/Resources/Private/Language/locallang.xlf:disableDragModal',
];
$GLOBALS['TYPO3_USER_SETTINGS']['showitem'] = str_replace(
'recursiveDelete',
'recursiveDelete,disableDragModal',
$GLOBALS['TYPO3_USER_SETTINGS']['showitem'],
);