Commit e3f9dcfd authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] Remove deprecated TypoScript Renderer

parent 3cf04510
......@@ -29,11 +29,8 @@ use SGalinski\DfTabs\DataProvider\AbstractBaseDataProvider;
use SGalinski\DfTabs\Domain\Repository\TabRepository;
use SGalinski\DfTabs\Service\ConfigurationService;
use SGalinski\DfTabs\View\FluidView;
use SGalinski\DfTabs\View\TypoScriptView;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
/**
......@@ -86,24 +83,8 @@ class PluginController extends AbstractPlugin {
* @return FluidView
*/
protected function getRenderer($tabId) {
$renderer = NULL;
/** @var TypoScriptFrontendController $tsfe */
$tsfe = $GLOBALS['TSFE'];
if ($this->pluginConfiguration['renderer'] === 'TypoScript' || !$this->pluginConfiguration['renderer']) {
/** @var TypoScriptView $renderer */
$renderer = GeneralUtility::makeInstance(TypoScriptView::class);
$renderer->addPluginConfiguration($this->pluginConfiguration, $tabId);
$renderer->injectPageRenderer(GeneralUtility::makeInstance(PageRenderer::class));
$renderer->injectContentObject($this->cObj);
$repository = $this->getTabRepository();
$records = $repository->getRecords();
$renderer->addInlineJavaScriptCode($records, $this->pluginConfiguration['mode'], $tabId);
} elseif ($this->pluginConfiguration['renderer'] === 'Fluid') {
/** @var FluidView $renderer */
$renderer = GeneralUtility::makeInstance(FluidView::class, $this->pluginConfiguration);
}
/** @var FluidView $renderer */
$renderer = GeneralUtility::makeInstance(FluidView::class, $this->pluginConfiguration);
return $renderer;
}
......
......@@ -114,7 +114,7 @@ abstract class AbstractDataBaseDataProvider extends AbstractBaseDataProvider {
'dontCheckPid' => 1
];
if (\is_array($this->pluginConfiguration['records.'])) {
if (\array_key_exists('records.', $this->pluginConfiguration) && \is_array($this->pluginConfiguration['records.'])) {
$configuration = \array_merge($configuration, $this->pluginConfiguration['records.']);
}
......
......@@ -38,7 +38,7 @@ final class FactoryDataProvider {
* to instantiate the table instance with needed information's.
*
* @throws GenericException if no valid data provider could be created
* @param string $type pages, tt_content, typoscript, ...
* @param string $type pages, tt_content ...
* @param array $pluginConfiguration
* @param ContentObjectRenderer $contentObject
* @return AbstractBaseDataProvider
......@@ -49,8 +49,6 @@ final class FactoryDataProvider {
$dataProvider = GeneralUtility::makeInstance(ContentDataProvider::class);
} elseif ($type === 'pages') {
$dataProvider = GeneralUtility::makeInstance(PagesDataProvider::class);
} elseif ($type === 'typoscript') {
$dataProvider = GeneralUtility::makeInstance(TypoScriptDataProvider::class);
} else {
throw new GenericException('No data provider matched your request!');
}
......
<?php
namespace SGalinski\DfTabs\DataProvider;
/***************************************************************
* 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!
***************************************************************/
/**
* Data Provider for plain typoscript
*/
class TypoScriptDataProvider extends AbstractBaseDataProvider {
/**
* Returns the tab content for the given typoscript object
*
* @param int $uid
* @return string
*/
public function getTabContent($uid) {
return $this->contentObject->stdWrap(
'',
$this->pluginConfiguration['stdWrap.']['typoscriptData.']['tab' . $uid . '.']
);
}
/**
* Returns an empty string as the titles should be configured with typoscript
*
* @param int $uid
* @return string
*/
public function getTitle($uid) {
return '';
}
/**
* Returns the link data for this typoscript element
*
* @param int $uid
* @return string
*/
public function getLinkData($uid) {
return $this->contentObject->stdWrap(
'',
$this->pluginConfiguration['stdWrap.']['typoscriptLinks.']['tab' . $uid . '.']
);
}
}
......@@ -138,10 +138,16 @@ class ConfigurationService {
if ($value !== '') {
$configuration['autoPlayInterval'] = (int)$value;
}
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'animationSpeed'));
if ($value !== '') {
$configuration['animationSpeed'] = (int)$value;
// this has to be a try catch for now, since animationSpeed was never a Setting inside of our flexform.
// when the Plugin has not been updated, this will stay, throwing an error in php8+
try {
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'animationSpeed'));
if ($value !== '') {
$configuration['animationSpeed'] = (int) $value;
}
}
catch (\Exception $e) {
$configuration['animationSpeed'] = 0;
}
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'mode'));
......@@ -155,14 +161,25 @@ class ConfigurationService {
}
### BEGIN Compatibility Code ###
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'pages'));
if ($value !== '') {
$configuration['data'] = $value;
// try catch for reasons explained above
try {
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'pages'));
if ($value !== '') {
$configuration['data'] = $value;
}
}
catch (\Exception $e) {
$configuration['data'] = '';
}
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'tt_content'));
if ($value !== '') {
$configuration['data'] = $value;
try {
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'tt_content'));
if ($value !== '') {
$configuration['data'] = $value;
}
}
catch (\Exception $e) {
$configuration['data'] = '';
}
### END Compatibility Code ###
......@@ -176,10 +193,7 @@ class ConfigurationService {
$configuration['hashName'] = $value;
}
$value = \trim($this->controllerContext->pi_getFFvalue($data, 'renderer'));
if ($value !== '') {
$configuration['renderer'] = $value;
}
$configuration['renderer'] = 'Fluid';
return $configuration;
}
......
......@@ -147,7 +147,7 @@ class TypoScriptView implements SingletonInterface {
hashName: "' . $config['hashName'] . '",
changeHashOnTabChange: ' . ($config['changeHashOnTabChange'] ? 'true' : 'false') . ',
pollingInterval: ' . $config['pollingInterval'] . ',
animationSpeed: ' . $config['animationSpeed'] . ',
animationSpeed: ' . ($config['animationSpeed'] ?? 0). ',
startIndex: ' . $config['startIndex'] . ',
onBeforeInitialize: ' . $config['events.']['onBeforeInitialize'] . ',
onAfterInitialize: ' . $config['events.']['onAfterInitialize'] . ',
......
......@@ -83,6 +83,19 @@
</config>
</TCEforms>
</autoPlayInterval>
<animationSpeed>
<TCEforms>
<label>LLL:EXT:df_tabs/Resources/Private/Language/locallang.xlf:flexform.sheets.general.animationSpeed</label>
<description>LLL:EXT:df_tabs/Resources/Private/Language/locallang.xlf:flexform.sheets.general.autoPlayInterval.description</description>
<config>
<type>input</type>
<size>5</size>
<max>5</max>
<default>400</default>
<eval>trim,int</eval>
</config>
</TCEforms>
</animationSpeed>
<enableMouseOver>
<TCEforms>
......
......@@ -5,7 +5,7 @@ plugin.tx_dftabs_plugin1 {
}
# cat=plugin.tx_dftabs_plugin1/settings; type=text; label=Defines the Renderer that is used
renderer = TypoScript
renderer = Fluid
# Fluid settings
view {
......
......@@ -30,19 +30,11 @@ Furthermore, you can define an auto-play mechanism with a custom interval to imp
#### Fluid Renderer
If you want to use the new Fluid Renderer, very little configuration is necessary. Just overwrite the following in your TypoScript Configuration:
```TypoScript
plugin.tx_dftabs_plugin1.renderer = Fluid
```
The output can be completely controlled from within the Fluid-Template `(EXT:df_tabs/Resources/Private/Templates/Standard/Tabs.html)`.
Just overwrite it to adjust it to your needs.
Please note that the Fluid Renderer does not come with preconfigured CSS or JavaScript. You have to add this on your own.
#### TypoScript Renderer (deprecated)
##### TypoScript Constants
```TypoScript
......
......@@ -42,9 +42,6 @@ class Tx_DfTabs_DataProvider_FactoryDataProviderTest extends Tx_DfTabs_BaseTestC
'pages' => [
'pages', 'Tx_DfTabs_DataProvider_PagesDataProvider'
],
'typoscript' => [
'typoscript', 'Tx_DfTabs_DataProvider_TypoScriptDataProvider'
],
];
}
......
<?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!
***************************************************************/
require_once(t3lib_extMgm::extPath('df_tabs') . 'Tests/Unit/BaseTestCase.php');
require_once(t3lib_extMgm::extPath('df_tabs') . 'Classes/DataProvider/InterfaceDataProvider.php');
/**
* Test case for class Tx_DfTabs_DataProvider_TypoScriptDataProvider.
*/
class Tx_DfTabs_DataProvider_TypoScriptDataProviderTest extends Tx_DfTabs_BaseTestCase {
/**
* @var Tx_DfTabs_DataProvider_TypoScriptDataProvider
*/
protected $fixture;
/**
* @var tslib_cObj
*/
protected $contentObject;
/**
* @return void
*/
public function setUp() {
$this->fixture = new Tx_DfTabs_DataProvider_TypoScriptDataProvider();
/** @noinspection PhpParamsInspection */
$this->contentObject = $this->getMock('tslib_cObj');
$this->fixture->injectContentObject($this->contentObject);
}
/**
* @return void
*/
public function tearDown() {
unset($this->fixture);
}
/**
* @test
* @return void
*/
public function getTabContentReturnsTheResultsOfDedicatedStandardWraps() {
$pluginConfiguration = [
'stdWrap.' => [
'typoscriptData.' => [
'tab1.' => [
'foo' => 'bar',
],
],
],
];
$this->fixture->injectPluginConfiguration($pluginConfiguration);
/** @noinspection PhpUndefinedMethodInspection */
$this->contentObject->expects($this->once())->method('stdWrap')
->with('', ['foo' => 'bar'])->will($this->returnValue('Foo'));
$this->assertSame('Foo', $this->fixture->getTabContent(1));
}
/**
* @test
* @return void
*/
public function getLinkDataReturnsTheResultsOfDedicatedStandardWraps() {
$pluginConfiguration = [
'stdWrap.' => [
'typoscriptLinks.' => [
'tab1.' => [
'foo' => 'bar',
],
],
],
];
$this->fixture->injectPluginConfiguration($pluginConfiguration);
/** @noinspection PhpUndefinedMethodInspection */
$this->contentObject->expects($this->once())->method('stdWrap')
->with('', ['foo' => 'bar'])->will($this->returnValue('Foo'));
$this->assertSame('Foo', $this->fixture->getLinkData(1));
}
}
......@@ -2,6 +2,7 @@
- Dropped TYPO3 9 support
- Dropped php 7.3 support
- removed deprecated TypoScript Renderer
# Version 7 Breaking Changes
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment