Skip to content
Snippets Groups Projects
Commit 589663be authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

Merge branch 'upgrade_TYPO3v12_phase3' into 'master'

[TASK] Prepare TYPO3 12

See merge request !8
parents 05e6af60 9e0a4579
No related branches found
No related tags found
1 merge request!8[TASK] Prepare TYPO3 12
Showing
with 140 additions and 242 deletions
<?php <?php
/** /***************************************************************
* * Copyright notice
* Copyright notice
* *
* (c) sgalinski Internet Services (https://www.sgalinski.de) * (c) sgalinski Internet Services (https://www.sgalinski.de)
* *
* All rights reserved * All rights reserved
* *
* This script is part of the TYPO3 project. The TYPO3 project is * This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify * free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* The GNU General Public License can be found at * The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html. * http://www.gnu.org/copyleft/gpl.html.
* *
* This script is distributed in the hope that it will be useful, * This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
*/ ***************************************************************/
namespace SGalinski\ContentReplacer\Middleware; namespace SGalinski\ContentReplacer\Middleware;
...@@ -51,20 +50,20 @@ class ContentReplacerMiddleware implements MiddlewareInterface { ...@@ -51,20 +50,20 @@ class ContentReplacerMiddleware implements MiddlewareInterface {
* *
* @var array * @var array
*/ */
protected $extensionConfiguration = []; protected array $extensionConfiguration = [];
/** /**
* @var TermRepository * @var TermRepository
*/ */
protected $termRepository; protected TermRepository $termRepository;
/** /**
* Constructor: Initializes the internal class properties. * Constructor: Initializes the internal class properties.
* *
* Note: The extension configuration array consists of the global and typoscript configuration. * Note: The extension configuration array consists of the global and typoscript configuration.
* *
* @throws ImmediateResponseException * @throws ImmediateResponseException
*/ */
public function __construct() { public function __construct() {
$this->extensionConfiguration = $this->prepareConfiguration(); $this->extensionConfiguration = $this->prepareConfiguration();
$this->termRepository = GeneralUtility::makeInstance(TermRepository::class); $this->termRepository = GeneralUtility::makeInstance(TermRepository::class);
...@@ -88,7 +87,6 @@ class ContentReplacerMiddleware implements MiddlewareInterface { ...@@ -88,7 +87,6 @@ class ContentReplacerMiddleware implements MiddlewareInterface {
$content = $this->parseAndReplace($customParser, $content); $content = $this->parseAndReplace($customParser, $content);
} }
// StreamFactory is not available in TYPO3 9 yet.
$streamFactory = GeneralUtility::makeInstance(StreamFactory::class); $streamFactory = GeneralUtility::makeInstance(StreamFactory::class);
$stream = $streamFactory->createStream($content); $stream = $streamFactory->createStream($content);
...@@ -140,12 +138,12 @@ class ContentReplacerMiddleware implements MiddlewareInterface { ...@@ -140,12 +138,12 @@ class ContentReplacerMiddleware implements MiddlewareInterface {
break; break;
} }
$occurences = $parser->parse($content); $occurrences = $parser->parse($content);
if (!count($occurences)) { if (!count($occurrences)) {
break; break;
} }
foreach ($occurences as $category => $terms) { foreach ($occurrences as $category => $terms) {
$content = $parser->replaceByCategory($category, $terms, $content); $content = $parser->replaceByCategory($category, $terms, $content);
} }
} }
...@@ -154,12 +152,12 @@ class ContentReplacerMiddleware implements MiddlewareInterface { ...@@ -154,12 +152,12 @@ class ContentReplacerMiddleware implements MiddlewareInterface {
} }
/** /**
* Returns the merged extension configuration of the global configuration and the typoscript * Returns the merged extension configuration of the global configuration and the typoscript
* settings. * settings.
* *
* @return array * @return array
* @throws ImmediateResponseException * @throws ImmediateResponseException
*/ */
public function prepareConfiguration(): array { public function prepareConfiguration(): array {
$extensionConfiguration = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['content_replacer'] ?? []; $extensionConfiguration = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['content_replacer'] ?? [];
......
<?php <?php
namespace SGalinski\ContentReplacer\Repository;
/*************************************************************** /***************************************************************
* Copyright notice * Copyright notice
* *
* (c) sgalinski Internet Services <https://www.sgalinski.de> * (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved * All rights reserved
* *
* This script is part of the TYPO3 project. The TYPO3 project is * This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify * free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* The GNU General Public License can be found at * The GNU General Public License can be found at
...@@ -25,9 +23,14 @@ namespace SGalinski\ContentReplacer\Repository; ...@@ -25,9 +23,14 @@ namespace SGalinski\ContentReplacer\Repository;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
namespace SGalinski\ContentReplacer\Repository;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Exception;
use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
...@@ -41,9 +44,11 @@ class TermRepository { ...@@ -41,9 +44,11 @@ class TermRepository {
* @param string $category * @param string $category
* @param array $storagePageIds * @param array $storagePageIds
* @return array * @return array
* @throws \UnexpectedValueException * @throws Exception
* @throws AspectNotFoundException
*/ */
public function fetchTerms(array $filterTerms, $category, array $storagePageIds) { public function fetchTerms(array $filterTerms, string $category, array $storagePageIds): array {
$context = GeneralUtility::makeInstance(Context::class);
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_content_replacer_term'); $queryBuilder = $connectionPool->getQueryBuilderForTable('tx_content_replacer_term');
$queryBuilder->select( $queryBuilder->select(
...@@ -62,10 +67,10 @@ class TermRepository { ...@@ -62,10 +67,10 @@ class TermRepository {
'category', 'category',
'category.uid = term.category_uid' 'category.uid = term.category_uid'
)->where( )->where(
$queryBuilder->expr()->andX( $queryBuilder->expr()->and(
$queryBuilder->expr()->in( $queryBuilder->expr()->in(
'term', 'term',
$queryBuilder->createNamedParameter($filterTerms, Connection::PARAM_STR_ARRAY) $queryBuilder->createNamedParameter($filterTerms, ArrayParameterType::STRING)
), ),
$queryBuilder->expr()->in('term.sys_language_uid', [-1, 0]), $queryBuilder->expr()->in('term.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
...@@ -78,27 +83,25 @@ class TermRepository { ...@@ -78,27 +83,25 @@ class TermRepository {
$queryBuilder->andWhere( $queryBuilder->andWhere(
$queryBuilder->expr()->in( $queryBuilder->expr()->in(
'term.pid', 'term.pid',
$queryBuilder->createNamedParameter($storagePageIds, Connection::PARAM_INT_ARRAY) $queryBuilder->createNamedParameter($storagePageIds, ArrayParameterType::INTEGER)
) )
); );
} }
$results = $queryBuilder->execute()->fetchAll(); $results = $queryBuilder->executeQuery()->fetchAllAssociative();
$terms = []; $terms = [];
$typoScriptFrontendController = $GLOBALS['TSFE']; $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); $languageAspect = $context->getAspect('language');
$sysLanguageId = $languageAspect->getId(); $sysLanguageId = $languageAspect->getId();
$sysLanguageOverlay = $languageAspect->getOverlayType();
foreach ($results as $term) { foreach ($results as $term) {
if ($sysLanguageId) { if ($sysLanguageId > 0) {
// This bit of code is bad performancewise, we should consider fetching relevant records via // This bit of code is bad performancewise, we should consider fetching relevant records via
// one single db call instead of looping through found default language records and fetching overlays // one single db call instead of looping through found default language records and fetching overlays
// for each of these separately // for each of these separately
$term = $typoScriptFrontendController->sys_page->getRecordOverlay( $term = $pageRepository->getLanguageOverlay(
'tx_content_replacer_term', 'tx_content_replacer_term',
$term, $term,
$sysLanguageId, $languageAspect
$sysLanguageOverlay
); );
} }
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
/*************************************************************** /***************************************************************
* Copyright notice * Copyright notice
* *
* (c) sgalinski Internet Services <https://www.sgalinski.de> * (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved * All rights reserved
* *
* This script is part of the TYPO3 project. The TYPO3 project is * This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify * free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* The GNU General Public License can be found at * The GNU General Public License can be found at
...@@ -25,7 +26,9 @@ ...@@ -25,7 +26,9 @@
namespace SGalinski\ContentReplacer\Service; namespace SGalinski\ContentReplacer\Service;
use Doctrine\DBAL\Exception;
use SGalinski\ContentReplacer\Repository\TermRepository; use SGalinski\ContentReplacer\Repository\TermRepository;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager; use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
...@@ -40,19 +43,19 @@ abstract class AbstractParserService { ...@@ -40,19 +43,19 @@ abstract class AbstractParserService {
* *
* @var array * @var array
*/ */
protected $extensionConfiguration = []; protected array $extensionConfiguration = [];
/** /**
* lib.parseFunc_RTE configuration * lib.parseFunc_RTE configuration
* *
* @var array * @var array
*/ */
protected $parseFunc = []; protected array $parseFunc = [];
/** /**
* @var TermRepository * @var TermRepository
*/ */
protected $termRepository; protected TermRepository $termRepository;
/** /**
* Constructor: Initializes the internal class properties. * Constructor: Initializes the internal class properties.
...@@ -69,7 +72,7 @@ abstract class AbstractParserService { ...@@ -69,7 +72,7 @@ abstract class AbstractParserService {
* @param array $extensionConfiguration * @param array $extensionConfiguration
* @return void * @return void
*/ */
public function setExtensionConfiguration(array $extensionConfiguration) { public function setExtensionConfiguration(array $extensionConfiguration): void {
$this->extensionConfiguration = $extensionConfiguration; $this->extensionConfiguration = $extensionConfiguration;
} }
...@@ -79,7 +82,7 @@ abstract class AbstractParserService { ...@@ -79,7 +82,7 @@ abstract class AbstractParserService {
* @param TermRepository $repository * @param TermRepository $repository
* @return void * @return void
*/ */
public function injectTermRepository(TermRepository $repository) { public function injectTermRepository(TermRepository $repository): void {
$this->termRepository = $repository; $this->termRepository = $repository;
} }
...@@ -96,7 +99,7 @@ abstract class AbstractParserService { ...@@ -96,7 +99,7 @@ abstract class AbstractParserService {
* @param string $termName * @param string $termName
* @return string * @return string
*/ */
protected function prepareReplacementTerm($replacement, $stdWrap, $termName) { protected function prepareReplacementTerm(string $replacement, string $stdWrap, string $termName): string {
$cObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); $cObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
if ($replacement !== '') { if ($replacement !== '') {
...@@ -132,10 +135,11 @@ abstract class AbstractParserService { ...@@ -132,10 +135,11 @@ abstract class AbstractParserService {
* *
* @param array $terms * @param array $terms
* @param string $category * @param string $category
* @return string * @return array
* @throws \UnexpectedValueException * @throws Exception
* @throws AspectNotFoundException
*/ */
protected function prepareFoundTerms(array &$terms, string $category) { protected function prepareFoundTerms(array &$terms, string $category): array {
$terms['*'] = []; $terms['*'] = [];
$termNames = array_keys($terms); $termNames = array_keys($terms);
$storagePageIds = GeneralUtility::intExplode(',', $this->extensionConfiguration['storagePid'], TRUE); $storagePageIds = GeneralUtility::intExplode(',', $this->extensionConfiguration['storagePid'], TRUE);
...@@ -143,10 +147,7 @@ abstract class AbstractParserService { ...@@ -143,10 +147,7 @@ abstract class AbstractParserService {
$configuredTerms = $this->termRepository->fetchTerms($termNames, $category, $storagePageIds); $configuredTerms = $this->termRepository->fetchTerms($termNames, $category, $storagePageIds);
$terms = array_merge_recursive($terms, $configuredTerms); $terms = array_merge_recursive($terms, $configuredTerms);
$defaultReplacement = (is_array($terms['*']) ? $terms['*'] : ''); return (is_array($terms['*']) ? $terms['*'] : []);
unset($terms['*']);
return $defaultReplacement;
} }
/** /**
...@@ -157,7 +158,7 @@ abstract class AbstractParserService { ...@@ -157,7 +158,7 @@ abstract class AbstractParserService {
* @param string $content * @param string $content
* @return array * @return array
*/ */
abstract public function parse($content); abstract public function parse(string $content): array;
/** /**
* Replaces the given terms with their related replacement values. * Replaces the given terms with their related replacement values.
...@@ -168,5 +169,5 @@ abstract class AbstractParserService { ...@@ -168,5 +169,5 @@ abstract class AbstractParserService {
* @param string $content * @param string $content
* @return string * @return string
*/ */
abstract public function replaceByCategory($category, array $terms, $content); abstract public function replaceByCategory(string $category, array $terms, string $content): string;
} }
<?php <?php
namespace SGalinski\ContentReplacer\Service;
/*************************************************************** /***************************************************************
* Copyright notice * Copyright notice
* *
* (c) sgalinski Internet Services <https://www.sgalinski.de> * (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved * All rights reserved
* *
* This script is part of the TYPO3 project. The TYPO3 project is * This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify * free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* The GNU General Public License can be found at * The GNU General Public License can be found at
...@@ -25,6 +23,11 @@ namespace SGalinski\ContentReplacer\Service; ...@@ -25,6 +23,11 @@ namespace SGalinski\ContentReplacer\Service;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
namespace SGalinski\ContentReplacer\Service;
use Doctrine\DBAL\Exception;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
/** /**
* Substitution service that parses and replaces special span tags inside the code * Substitution service that parses and replaces special span tags inside the code
* *
...@@ -36,7 +39,7 @@ class CustomParserService extends AbstractParserService { ...@@ -36,7 +39,7 @@ class CustomParserService extends AbstractParserService {
/** /**
* @var string * @var string
*/ */
protected $wrapCharacter = ''; protected string $wrapCharacter = '';
/** /**
* Sets the wrap character * Sets the wrap character
...@@ -44,7 +47,7 @@ class CustomParserService extends AbstractParserService { ...@@ -44,7 +47,7 @@ class CustomParserService extends AbstractParserService {
* @param string $wrapCharacter * @param string $wrapCharacter
* @return void * @return void
*/ */
public function setWrapCharacter($wrapCharacter) { public function setWrapCharacter(string $wrapCharacter): void {
$this->wrapCharacter = $wrapCharacter; $this->wrapCharacter = $wrapCharacter;
} }
...@@ -64,7 +67,7 @@ class CustomParserService extends AbstractParserService { ...@@ -64,7 +67,7 @@ class CustomParserService extends AbstractParserService {
* @param string $content * @param string $content
* @return array * @return array
*/ */
public function parse($content) { public function parse(string $content): array {
$matches = []; $matches = [];
$maximumLengthPattern = '+'; $maximumLengthPattern = '+';
...@@ -94,9 +97,10 @@ class CustomParserService extends AbstractParserService { ...@@ -94,9 +97,10 @@ class CustomParserService extends AbstractParserService {
* @param array $terms * @param array $terms
* @param string $content * @param string $content
* @return string * @return string
* @throws \UnexpectedValueException * @throws Exception
* @throws AspectNotFoundException
*/ */
public function replaceByCategory($category, array $terms, $content) { public function replaceByCategory(string $category, array $terms, string $content): string {
$search = $replace = []; $search = $replace = [];
$defaultReplacement = $this->prepareFoundTerms($terms, $category); $defaultReplacement = $this->prepareFoundTerms($terms, $category);
$char = preg_quote($this->wrapCharacter, '/'); $char = preg_quote($this->wrapCharacter, '/');
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
/*************************************************************** /***************************************************************
* Copyright notice * Copyright notice
* *
* (c) sgalinski Internet Services <https://www.sgalinski.de> * (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved * All rights reserved
* *
* This script is part of the TYPO3 project. The TYPO3 project is * This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify * free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* The GNU General Public License can be found at * The GNU General Public License can be found at
...@@ -25,6 +26,8 @@ ...@@ -25,6 +26,8 @@
namespace SGalinski\ContentReplacer\Service; namespace SGalinski\ContentReplacer\Service;
use Doctrine\DBAL\Exception;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Log\Logger; use TYPO3\CMS\Core\Log\Logger;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
...@@ -54,7 +57,7 @@ class SpanParserService extends AbstractParserService { ...@@ -54,7 +57,7 @@ class SpanParserService extends AbstractParserService {
* @param string $content * @param string $content
* @return array * @return array
*/ */
public function parse($content): array { public function parse(string $content): array {
$matches = []; $matches = [];
$prefix = (string) ($this->extensionConfiguration['prefix'] ?? ''); $prefix = (string) ($this->extensionConfiguration['prefix'] ?? '');
if (ExtensionManagementUtility::isLoaded('headless')) { if (ExtensionManagementUtility::isLoaded('headless')) {
...@@ -90,7 +93,7 @@ class SpanParserService extends AbstractParserService { ...@@ -90,7 +93,7 @@ class SpanParserService extends AbstractParserService {
foreach ($classes as $classIndex => $class) { foreach ($classes as $classIndex => $class) {
$class = trim($class); $class = trim($class);
if ($prefix !== '' && FALSE !== strpos($class, $prefix)) { if ($prefix !== '' && str_contains($class, $prefix)) {
$category = str_replace($prefix, '', $class); $category = str_replace($prefix, '', $class);
unset($classes[$classIndex]); unset($classes[$classIndex]);
break; break;
...@@ -123,9 +126,10 @@ class SpanParserService extends AbstractParserService { ...@@ -123,9 +126,10 @@ class SpanParserService extends AbstractParserService {
* @param array $terms * @param array $terms
* @param string $content * @param string $content
* @return string * @return string
* @throws \UnexpectedValueException * @throws Exception
* @throws AspectNotFoundException
*/ */
public function replaceByCategory($category, array $terms, $content): string { public function replaceByCategory(string $category, array $terms, string $content): string {
$search = $replace = []; $search = $replace = [];
$defaultReplacement = $this->prepareFoundTerms($terms, $category); $defaultReplacement = $this->prepareFoundTerms($terms, $category);
foreach ($terms as $termName => $term) { foreach ($terms as $termName => $term) {
...@@ -138,7 +142,7 @@ class SpanParserService extends AbstractParserService { ...@@ -138,7 +142,7 @@ class SpanParserService extends AbstractParserService {
if (ExtensionManagementUtility::isLoaded('headless')) { if (ExtensionManagementUtility::isLoaded('headless')) {
// when EXT:headless is present, content will be escaped (JSON output), so we got to add some small details: // when EXT:headless is present, content will be escaped (JSON output), so we got to add some small details:
$search[$termName] = '/' . $search[$termName] = '/' .
'<span ' . preg_quote($term['pre'], '/') . '<span ' . preg_quote($term['pre'] ?? '', '/') .
'class=\\\\"([^"]*?)' . $searchClass . '([^"]*?)\\\\"' . 'class=\\\\"([^"]*?)' . $searchClass . '([^"]*?)\\\\"' .
preg_quote($term['post'], '/') . '>' . preg_quote($term['post'], '/') . '>' .
'\s*?' . preg_quote($term['term'], '/') . '\s*?' . '\s*?' . preg_quote($term['term'], '/') . '\s*?' .
...@@ -146,10 +150,10 @@ class SpanParserService extends AbstractParserService { ...@@ -146,10 +150,10 @@ class SpanParserService extends AbstractParserService {
'/i'; '/i';
} else { } else {
$search[$termName] = '/' . $search[$termName] = '/' .
'<span ' . preg_quote($term['pre'], '/') . '<span ' . preg_quote($term['pre'] ?? '', '/') .
'class="([^"]*?)' . $searchClass . '([^"]*?)"' . 'class="([^"]*?)' . $searchClass . '([^"]*?)"' .
preg_quote($term['post'], '/') . '>' . preg_quote($term['post'] ?? '', '/') . '>' .
'\s*?' . preg_quote($term['term'], '/') . '\s*?' . '\s*?' . preg_quote($term['term'] ?? '', '/') . '\s*?' .
'<\/span>' . '<\/span>' .
'/i'; '/i';
} }
...@@ -160,7 +164,7 @@ class SpanParserService extends AbstractParserService { ...@@ -160,7 +164,7 @@ class SpanParserService extends AbstractParserService {
$termName $termName
); );
if (trim($term['pre']) !== '' || trim($term['post']) !== '' || trim($term['classAttribute']) !== '') { if (trim($term['pre'] ?? '') !== '' || trim($term['post'] ?? '') !== '' || trim($term['classAttribute'] ?? '') !== '') {
$attributes = trim($term['pre'] . ' ' . $term['post'] . ' ' . $term['classAttribute']); $attributes = trim($term['pre'] . ' ' . $term['post'] . ' ' . $term['classAttribute']);
$replace[$termName] = '<span ' . $attributes . '>' . $replace[$termName] . '</span>'; $replace[$termName] = '<span ' . $attributes . '>' . $replace[$termName] . '</span>';
} }
......
<?php <?php
/**
* use SGalinski\ContentReplacer\Middleware\ContentReplacerMiddleware;
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
return [ return [
'frontend' => [ 'frontend' => [
'sgalinski/content-replacer' => [ 'sgalinski/content-replacer' => [
'target' => \SGalinski\ContentReplacer\Middleware\ContentReplacerMiddleware::class, 'target' => ContentReplacerMiddleware::class,
'description' => '', 'description' => '',
'before' => [ 'before' => [
'typo3/cms-frontend/content-length-headers' 'typo3/cms-frontend/content-length-headers'
......
<?php <?php
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
......
<?php <?php
defined('TYPO3') or die(); use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( ExtensionManagementUtility::addStaticFile(
'content_replacer', 'content_replacer',
'Configuration/Typoscript/', 'Configuration/Typoscript/',
'Content Replacer' 'Content Replacer'
......
<?php <?php
defined('TYPO3') or die(); use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToInsertRecords('tx_content_replacer_category'); ExtensionManagementUtility::addToInsertRecords(
'tx_content_replacer_category'
);
<?php <?php
defined('TYPO3') or die(); use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToInsertRecords('tx_content_replacer_term'); ExtensionManagementUtility::addToInsertRecords(
'tx_content_replacer_term'
);
<?php <?php
if (!defined('TYPO3')) {
die('Access denied.');
}
// Path to the localisation file // Path to the localisation file
$localisationFilePath = 'LLL:EXT:content_replacer/Resources/Private/Language/locallang_db.xlf:'; $localisationFilePath = 'LLL:EXT:content_replacer/Resources/Private/Language/locallang_db.xlf:';
$generalLabelsPrefix = 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.'; $generalLabelsPrefix = 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.';
/** @var array using TCA Notation */
$columns = [ $columns = [
'ctrl' => [ 'ctrl' => [
'title' => $localisationFilePath . 'tx_content_replacer_category', 'title' => $localisationFilePath . 'tx_content_replacer_category',
'label' => 'category', 'label' => 'category',
'tstamp' => 'tstamp', 'tstamp' => 'tstamp',
'crdate' => 'crdate', 'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'versioningWS' => TRUE, 'versioningWS' => TRUE,
'origUid' => 't3_origuid', 'origUid' => 't3_origuid',
'default_sortby' => 'ORDER BY category', 'default_sortby' => 'ORDER BY category',
...@@ -24,6 +18,9 @@ $columns = [ ...@@ -24,6 +18,9 @@ $columns = [
'enablecolumns' => [ 'enablecolumns' => [
'disabled' => 'hidden' 'disabled' => 'hidden'
], ],
'security' => [
'ignorePageTypeRestriction' => 1
],
'searchFields' => 'category, description', 'searchFields' => 'category, description',
'iconfile' => 'EXT:content_replacer/Resources/Public/Icons/icon_tx_content_replacer_category.png', 'iconfile' => 'EXT:content_replacer/Resources/Public/Icons/icon_tx_content_replacer_category.png',
], ],
...@@ -53,8 +50,8 @@ $columns = [ ...@@ -53,8 +50,8 @@ $columns = [
'config' => [ 'config' => [
'type' => 'input', 'type' => 'input',
'size' => 40, 'size' => 40,
'max' => 256, 'eval' => 'trim,unique',
'eval' => 'trim,required,unique', 'required' => TRUE,
], ],
], ],
'description' => [ 'description' => [
......
<?php <?php
if (!defined('TYPO3')) {
die('Access denied.');
}
// Path to the localisation file // Path to the localisation file
$localisationFilePath = 'LLL:EXT:content_replacer/Resources/Private/Language/locallang_db.xlf:'; $localisationFilePath = 'LLL:EXT:content_replacer/Resources/Private/Language/locallang_db.xlf:';
$generalLabelsPrefix = 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.'; $generalLabelsPrefix = 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.';
/** @var array using TCA Notation */
$columns = [ $columns = [
'ctrl' => [ 'ctrl' => [
'title' => $localisationFilePath . 'tx_content_replacer_term', 'title' => $localisationFilePath . 'tx_content_replacer_term',
...@@ -20,7 +15,6 @@ $columns = [ ...@@ -20,7 +15,6 @@ $columns = [
'transOrigDiffSourceField' => 'l10n_diffsource', 'transOrigDiffSourceField' => 'l10n_diffsource',
'tstamp' => 'tstamp', 'tstamp' => 'tstamp',
'crdate' => 'crdate', 'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'versioningWS' => TRUE, 'versioningWS' => TRUE,
'origUid' => 't3_origuid', 'origUid' => 't3_origuid',
'groupName' => 'content_replacer', 'groupName' => 'content_replacer',
...@@ -31,6 +25,9 @@ $columns = [ ...@@ -31,6 +25,9 @@ $columns = [
'starttime' => 'starttime', 'starttime' => 'starttime',
'endtime' => 'endtime' 'endtime' => 'endtime'
], ],
'security' => [
'ignorePageTypeRestriction' => 1
],
'searchFields' => 'term, replacement, description', 'searchFields' => 'term, replacement, description',
'iconfile' => 'EXT:content_replacer/Resources/Public/Icons/icon_tx_content_replacer_term.png', 'iconfile' => 'EXT:content_replacer/Resources/Public/Icons/icon_tx_content_replacer_term.png',
], ],
...@@ -44,19 +41,7 @@ $columns = [ ...@@ -44,19 +41,7 @@ $columns = [
'sys_language_uid' => [ 'sys_language_uid' => [
'exclude' => TRUE, 'exclude' => TRUE,
'label' => $generalLabelsPrefix . 'language', 'label' => $generalLabelsPrefix . 'language',
'config' => [ 'config' => ['type' => 'language'],
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'default' => 0,
'items' => [
[
$generalLabelsPrefix . 'allLanguages',
-1,
'flags-multiple'
]
]
],
], ],
'l10n_parent' => [ 'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0', 'displayCond' => 'FIELD:sys_language_uid:>:0',
...@@ -65,7 +50,7 @@ $columns = [ ...@@ -65,7 +50,7 @@ $columns = [
'type' => 'select', 'type' => 'select',
'renderType' => 'selectSingle', 'renderType' => 'selectSingle',
'items' => [ 'items' => [
['', 0], ['label' => '', 'value' => 0],
], ],
'foreign_table' => 'tx_content_replacer_term', 'foreign_table' => 'tx_content_replacer_term',
'foreign_table_where' => 'AND tx_content_replacer_term.pid=###CURRENT_PID### ' . 'foreign_table_where' => 'AND tx_content_replacer_term.pid=###CURRENT_PID### ' .
...@@ -89,9 +74,7 @@ $columns = [ ...@@ -89,9 +74,7 @@ $columns = [
'exclude' => TRUE, 'exclude' => TRUE,
'label' => $generalLabelsPrefix . 'starttime', 'label' => $generalLabelsPrefix . 'starttime',
'config' => [ 'config' => [
'type' => 'input', 'type' => 'datetime',
'renderType' => 'inputDateTime',
'eval' => 'datetime,int',
'default' => 0 'default' => 0
] ]
], ],
...@@ -99,9 +82,7 @@ $columns = [ ...@@ -99,9 +82,7 @@ $columns = [
'exclude' => TRUE, 'exclude' => TRUE,
'label' => $generalLabelsPrefix . 'endtime', 'label' => $generalLabelsPrefix . 'endtime',
'config' => [ 'config' => [
'type' => 'input', 'type' => 'datetime',
'renderType' => 'inputDateTime',
'eval' => 'datetime,int',
'default' => 0, 'default' => 0,
'range' => [ 'range' => [
'upper' => mktime(0, 0, 0, 1, 1, 2038) 'upper' => mktime(0, 0, 0, 1, 1, 2038)
...@@ -114,8 +95,8 @@ $columns = [ ...@@ -114,8 +95,8 @@ $columns = [
'config' => [ 'config' => [
'type' => 'input', 'type' => 'input',
'size' => 40, 'size' => 40,
'max' => 256, 'eval' => 'trim',
'eval' => 'trim,required', 'required' => TRUE,
] ]
], ],
'category_uid' => [ 'category_uid' => [
...@@ -144,7 +125,6 @@ $columns = [ ...@@ -144,7 +125,6 @@ $columns = [
'config' => [ 'config' => [
'type' => 'input', 'type' => 'input',
'size' => 40, 'size' => 40,
'max' => 256,
'eval' => 'trim', 'eval' => 'trim',
'behaviour' => [ 'behaviour' => [
'allowLanguageSynchronization' => TRUE 'allowLanguageSynchronization' => TRUE
......
# Version 8 Breaking Changes
- Dropped TYPO3 10 and 11 support
- Dropped php 7 support
# Version 7 Breaking Changes # Version 7 Breaking Changes
- Dropped TYPO3 9 support - Dropped TYPO3 9 support
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
"support": { "support": {
"issues": "https://gitlab.sgalinski.de/typo3/content_replacer/issues" "issues": "https://gitlab.sgalinski.de/typo3/content_replacer/issues"
}, },
"version": "7.0.11", "version": "8.0.0-dev",
"require": { "require": {
"typo3/cms-core": "^10.4 || ^11.5" "typo3/cms-core": "^12.4"
}, },
"replace": { "replace": {
"sgalinski/content_replacer": "self.version" "sgalinski/content_replacer": "self.version"
......
...@@ -14,15 +14,15 @@ $EM_CONF['content_replacer'] = [ ...@@ -14,15 +14,15 @@ $EM_CONF['content_replacer'] = [
'title' => 'Content Replacer', 'title' => 'Content Replacer',
'description' => 'You need a fast substitution of terms with full support of typoscript, categories and RTE integration? If yes, the extension could be perfectly fit into your project. The performance is gained by wrapping of the replacement terms to simplify the parsing process.', 'description' => 'You need a fast substitution of terms with full support of typoscript, categories and RTE integration? If yes, the extension could be perfectly fit into your project. The performance is gained by wrapping of the replacement terms to simplify the parsing process.',
'category' => 'fe', 'category' => 'fe',
'version' => '7.0.11', 'version' => '8.0.0-dev',
'state' => 'stable', 'state' => 'stable',
'author' => 'Stefan Galinski', 'author' => 'Stefan Galinski',
'author_email' => 'stefan.galinski@gmail.com', 'author_email' => 'stefan.galinski@gmail.com',
'author_company' => 'domainFACTORY', 'author_company' => 'domainFACTORY',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '10.4.0-11.5.99', 'typo3' => '12.4.0-12.4.99',
'php' => '7.4.0-8.1.99', 'php' => '8.1.0-8.3.99',
], ],
'conflicts' => [ 'conflicts' => [
], ],
......
<?php
defined('TYPO3') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_content_replacer_category');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_content_replacer_term');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment