From a001e1feee01f058ce1cc72586187ad56b0647bb Mon Sep 17 00:00:00 2001 From: Torben Hansen Date: Fri, 1 Nov 2024 09:48:26 +0100 Subject: [PATCH] [!!!][TASK] Added TYPO3 13.4 compatibility --- .Build/composer.json | 24 +-- .Build/php-cs-fixer/.php-cs-fixer.php | 2 +- .Build/phpunit/FunctionalTests.xml | 1 + .github/workflows/CodeQuality.yml | 2 +- .github/workflows/UnitFunctionalTests.yml | 2 +- .github/workflows/documentation.yml | 17 +++ Classes/Controller/BannerController.php | 16 +- .../Domain/Repository/BannerRepository.php | 4 +- .../Updates/PluginToContentElementUpdater.php | 36 +++++ Configuration/Extbase/Persistence/Classes.php | 9 ++ Configuration/Flexforms/Flexform_plugin.xml | 138 ++++++++---------- Configuration/TCA/Overrides/tt_content.php | 29 +++- .../TCA/tx_sfbanners_domain_model_banner.php | 106 -------------- Configuration/TypoScript/setup.typoscript | 21 +-- Documentation/Breakingchanges/Index.rst | 7 + .../Introduction/Screenshots/Images.txt | 6 - .../Introduction/Screenshots/Index.rst | 4 +- Documentation/Settings.cfg | 73 --------- .../UsersManual/Installation/Index.rst | 2 +- .../UsersManual/SettingsForBanners/Index.rst | 2 +- Documentation/guides.xml | 18 +++ Makefile | 16 ++ README.md | 5 +- .../Repository/BannerRepositoryTest.php | 32 ++-- Tests/Unit/Domain/Model/BannerDemandTest.php | 29 +--- Tests/Unit/Domain/Model/BannerTest.php | 89 +++-------- composer.json | 2 +- ext_emconf.php | 4 +- ext_localconf.php | 37 ++--- ext_tables.sql | 59 -------- 30 files changed, 289 insertions(+), 503 deletions(-) create mode 100644 .github/workflows/documentation.yml create mode 100644 Classes/Updates/PluginToContentElementUpdater.php create mode 100644 Configuration/Extbase/Persistence/Classes.php delete mode 100755 Documentation/Introduction/Screenshots/Images.txt delete mode 100644 Documentation/Settings.cfg create mode 100644 Documentation/guides.xml create mode 100644 Makefile delete mode 100644 ext_tables.sql diff --git a/.Build/composer.json b/.Build/composer.json index c849906a..adf3caf2 100644 --- a/.Build/composer.json +++ b/.Build/composer.json @@ -9,21 +9,21 @@ ], "require": { "derhansen/sf_banners": "@dev", - "typo3/cms-core": "^12.4", - "php": ">=8.1" + "typo3/cms-core": "^13.4", + "php": ">=8.2" }, "require-dev": { "typo3/cms-composer-installers": "^5.0", - "typo3/cms-backend": "^12.4", - "typo3/cms-frontend": "^12.4", - "typo3/cms-extbase": "^12.4", - "typo3/cms-felogin": "^12.4", - "typo3/cms-fluid-styled-content": "^12.4", - "typo3/cms-fluid": "^12.4", - "typo3/cms-tstemplate": "^12.4", - "typo3/cms-install": "^12.4", - "typo3/cms-extensionmanager": "^12.4", - "typo3/testing-framework": "^8.0", + "typo3/cms-backend": "^13.4", + "typo3/cms-frontend": "^13.4", + "typo3/cms-extbase": "^13.4", + "typo3/cms-felogin": "^13.4", + "typo3/cms-fluid-styled-content": "^13.4", + "typo3/cms-fluid": "^13.4", + "typo3/cms-tstemplate": "^13.4", + "typo3/cms-install": "^13.4", + "typo3/cms-extensionmanager": "^13.4", + "typo3/testing-framework": "^9.0", "friendsofphp/php-cs-fixer": "^3.12.0", "saschaegerer/phpstan-typo3": "^1.8.3", "phpstan/extension-installer": "^1.1" diff --git a/.Build/php-cs-fixer/.php-cs-fixer.php b/.Build/php-cs-fixer/.php-cs-fixer.php index 9da14b1a..ada31038 100644 --- a/.Build/php-cs-fixer/.php-cs-fixer.php +++ b/.Build/php-cs-fixer/.php-cs-fixer.php @@ -61,7 +61,7 @@ 'single_line_empty_body' => false, 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], - ]) + ]) ->setFinder( PhpCsFixer\Finder::create() ->in(dirname(__DIR__ . '/../../../')) diff --git a/.Build/phpunit/FunctionalTests.xml b/.Build/phpunit/FunctionalTests.xml index 56618c73..3f2b5d67 100644 --- a/.Build/phpunit/FunctionalTests.xml +++ b/.Build/phpunit/FunctionalTests.xml @@ -8,6 +8,7 @@ stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" + failOnDeprecation="true" beStrictAboutTestsThatDoNotTestAnything="false" failOnWarning="true" failOnRisky="true" diff --git a/.github/workflows/CodeQuality.yml b/.github/workflows/CodeQuality.yml index 6f7aa2c1..db607938 100644 --- a/.github/workflows/CodeQuality.yml +++ b/.github/workflows/CodeQuality.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: env: - - { php: 8.1, coverage: 0} + - { php: 8.2, coverage: 0} env: ${{ matrix.env }} diff --git a/.github/workflows/UnitFunctionalTests.yml b/.github/workflows/UnitFunctionalTests.yml index b90995b9..3634f752 100644 --- a/.github/workflows/UnitFunctionalTests.yml +++ b/.github/workflows/UnitFunctionalTests.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.1', '8.2', '8.3'] + php: ['8.2', '8.3', '8.4'] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 00000000..79ac662e --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,17 @@ +name: test documentation + +on: [ push, pull_request ] + +jobs: + tests: + name: documentation + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test if the documentation will render without warnings + run: | + mkdir -p Documentation-GENERATED-temp \ + && docker run --rm --pull always -v $(pwd):/project \ + ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --fail-on-log diff --git a/Classes/Controller/BannerController.php b/Classes/Controller/BannerController.php index 363a8844..27a73600 100644 --- a/Classes/Controller/BannerController.php +++ b/Classes/Controller/BannerController.php @@ -17,17 +17,18 @@ use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Crypto\Random; use TYPO3\CMS\Core\Http\PropagateResponseException; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Frontend\Controller\ErrorController; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class BannerController extends ActionController { public function __construct( private readonly FrontendInterface $cacheInstance, - private readonly BannerRepository $bannerRepository + private readonly BannerRepository $bannerRepository, + private readonly Random $random ) { } @@ -56,7 +57,7 @@ public function clickAction(Banner $banner = null): ResponseInterface public function showAction(): ResponseInterface { $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); - $uniqueid = strtolower(substr(base64_encode(sha1(microtime())), 0, 9)); + $uniqueid = strtolower($this->random->generateRandomHexString(10)); $arguments = [ 'type' => $this->settings['ajaxPageTypeNum'], @@ -82,7 +83,7 @@ public function showAction(): ResponseInterface 'maxResults' => ($this->settings['maxResults'] ?? '') !== '' ? (int)$this->settings['maxResults'] : 0, ]; - $config = $this->hashService->appendHmac(json_encode($bannerConfig, JSON_THROW_ON_ERROR)); + $config = $this->hashService->appendHmac(json_encode($bannerConfig, JSON_THROW_ON_ERROR), self::class); $this->view->assignMultiple([ 'fetchUrl' => $fetchUrl, @@ -102,7 +103,7 @@ public function getBannersAction(array $bannerConfigs = []): ResponseInterface foreach ($bannerConfigs as $bannerConfig) { try { - $configString = $this->hashService->validateAndStripHmac($bannerConfig); + $configString = $this->hashService->validateAndStripHmac($bannerConfig, self::class); $config = json_decode($configString, true, 512, JSON_THROW_ON_ERROR); $result[] = [ 'uniqueId' => $config['uniqueId'], @@ -163,9 +164,4 @@ protected function getBannersByConfig(array $config): string return $ret; } - - protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController - { - return $GLOBALS['TSFE'] ?: null; - } } diff --git a/Classes/Domain/Repository/BannerRepository.php b/Classes/Domain/Repository/BannerRepository.php index 45ccb218..2c394707 100644 --- a/Classes/Domain/Repository/BannerRepository.php +++ b/Classes/Domain/Repository/BannerRepository.php @@ -38,10 +38,8 @@ public function initializeObject(): void /** * Returns banners matching the given demand - * - * @return array|QueryResultInterface */ - public function findDemanded(BannerDemand $demand) + public function findDemanded(BannerDemand $demand): array|QueryResultInterface { /* Override the default sorting for random mode. Must be called before createQuery() */ if ($demand->getDisplayMode() === 'allRandom') { diff --git a/Classes/Updates/PluginToContentElementUpdater.php b/Classes/Updates/PluginToContentElementUpdater.php new file mode 100644 index 00000000..6ddc81d1 --- /dev/null +++ b/Classes/Updates/PluginToContentElementUpdater.php @@ -0,0 +1,36 @@ + 'sfbanners_pi1', + ]; + } + + public function getTitle(): string + { + return 'ext:sf_banners: Migrate plugins to content elements'; + } + + public function getDescription(): string + { + return 'Migrates existing plugin records and backend user permissions used by ext:banners'; + } +} diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php new file mode 100644 index 00000000..889f431d --- /dev/null +++ b/Configuration/Extbase/Persistence/Classes.php @@ -0,0 +1,9 @@ + [ + 'tableName' => 'pages', + ], +]; diff --git a/Configuration/Flexforms/Flexform_plugin.xml b/Configuration/Flexforms/Flexform_plugin.xml index 5b32c567..265f21e4 100644 --- a/Configuration/Flexforms/Flexform_plugin.xml +++ b/Configuration/Flexforms/Flexform_plugin.xml @@ -6,86 +6,76 @@ array - - - reload - - select - selectSingle - - - LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.all - all - - - LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.allRandom - allRandom - - - LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.random - random - - - - + + reload + + select + selectSingle + + + + all + + + + allRandom + + + + random + + + - - - - - FIELD:settings.displayMode:=:all - FIELD:settings.displayMode:=:allRandom - - - - input - num - 5 - - + + + + FIELD:settings.displayMode:=:all + FIELD:settings.displayMode:=:allRandom + + + + number + 5 + - - 1 - - - group - db - pages - 3 - 50 - 0 - 1 - - - suggest - - - - + 1 + + + group + pages + 3 + 50 + 0 + 1 + + + suggest + + + - - - - select - selectTree - - parent - - TRUE - TRUE - - - sys_category - AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC - 10 - 10 - 0 - 999 - - + + + select + selectTree + + parent + + TRUE + TRUE + + + sys_category + AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC + 10 + 10 + 0 + 999 + diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index aef4361d..4e9e4b74 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -20,14 +20,31 @@ */ $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['sfbanners_pi1'] = 'pi_flexform'; ExtensionManagementUtility::addPiFlexFormValue( - 'sfbanners_pi1', - 'FILE:EXT:sf_banners/Configuration/Flexforms/Flexform_plugin.xml' + '*', + 'FILE:EXT:sf_banners/Configuration/Flexforms/Flexform_plugin.xml', + 'sfbanners_pi1' ); -/** - * Remove unused fields - */ -$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['sfbanners_pi1'] = 'layout,recursive,select_key,pages'; +$GLOBALS['TCA']['tt_content']['types']['sfbanners_pi1']['showitem'] = ' + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, + --palette--;;general, + --palette--;;headers, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin, + pi_flexform, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance, + --palette--;;frames, + --palette--;;appearanceLinks, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, + --palette--;;language, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, + --palette--;;hidden, + --palette--;;access, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories, + categories, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes, + rowDescription, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended, + '; /** * Default TypoScript diff --git a/Configuration/TCA/tx_sfbanners_domain_model_banner.php b/Configuration/TCA/tx_sfbanners_domain_model_banner.php index bb628d91..aa6b0af0 100644 --- a/Configuration/TCA/tx_sfbanners_domain_model_banner.php +++ b/Configuration/TCA/tx_sfbanners_domain_model_banner.php @@ -33,102 +33,6 @@ 'paletteLanguage' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource'], ], 'columns' => [ - 'sys_language_uid' => [ - 'exclude' => true, - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', - 'config' => [ - 'type' => 'language', - ], - ], - 'l10n_parent' => [ - 'displayCond' => 'FIELD:sys_language_uid:>:0', - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent', - 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'items' => [ - [ - 'label' => '', - 'value' => 0, - ], - ], - 'foreign_table' => 'tx_sfbanners_domain_model_banner', - 'foreign_table_where' => 'AND tx_sfbanners_domain_model_banner.pid=###CURRENT_PID### AND tx_sfbanners_domain_model_banner.sys_language_uid IN (-1,0)', - 'default' => 0, - ], - ], - 'l10n_diffsource' => [ - 'config' => [ - 'type' => 'passthrough', - ], - ], - 'hidden' => [ - 'exclude' => 1, - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', - 'config' => [ - 'type' => 'check', - 'renderType' => 'checkboxToggle', - 'default' => 0, - 'items' => [ - [ - 'label' => '', - 'invertStateDisplay' => false, - ], - ], - ], - ], - 'starttime' => [ - 'exclude' => 1, - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime', - 'config' => [ - 'type' => 'datetime', - 'default' => 0, - 'behaviour' => [ - 'allowLanguageSynchronization' => true, - ], - ], - ], - 'endtime' => [ - 'exclude' => 1, - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime', - 'config' => [ - 'type' => 'datetime', - 'default' => 0, - 'behaviour' => [ - 'allowLanguageSynchronization' => true, - ], - ], - ], - 'fe_group' => [ - 'exclude' => true, - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.fe_group', - 'config' => [ - 'type' => 'select', - 'renderType' => 'selectMultipleSideBySide', - 'size' => 5, - 'maxitems' => 20, - 'items' => [ - [ - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hide_at_login', - 'value' => -1, - ], - [ - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.any_login', - 'value' => -2, - ], - [ - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.usergroups', - 'value' => '--div--', - ], - ], - 'exclusiveKeys' => '-1,-2', - 'foreign_table' => 'fe_groups', - 'foreign_table_where' => 'ORDER BY fe_groups.title', - 'behaviour' => [ - 'allowLanguageSynchronization' => true, - ], - ], - ], 'title' => [ 'exclude' => 1, 'label' => 'LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:tx_sfbanners_domain_model_banner.title', @@ -181,16 +85,6 @@ ], 'minitems' => 0, 'maxitems' => 1, - // Use the imageoverlayPalette instead of the basicoverlayPalette, so links can be defined. - 'overrideChildTca' => [ - 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette', - ], - ], - ], ], ], 'html' => [ diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 66d15f45..6428299e 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -25,21 +25,10 @@ plugin.tx_sfbanners { } widgets { - bannerWidget = USER + bannerWidget = EXTBASEPLUGIN bannerWidget { - userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run extensionName = SfBanners pluginName = Pi1 - vendorName = DERHANSEN - switchableControllerActions { - Banner { - 1 = show - } - - Banner { - 2 = click - } - } settings < plugin.tx_sfbanners.settings persistence < plugin.tx_sfbanners.persistence @@ -48,14 +37,6 @@ plugin.tx_sfbanners { } } -config.tx_extbase.persistence.classes { - DERHANSEN\SfBanners\Domain\Model\Page { - mapping { - tableName = pages - } - } -} - # Include banner JS page.includeJSFooter { postscribe = EXT:sf_banners/Resources/Public/Js/Postscribe.js diff --git a/Documentation/Breakingchanges/Index.rst b/Documentation/Breakingchanges/Index.rst index 678434b5..d7075de6 100644 --- a/Documentation/Breakingchanges/Index.rst +++ b/Documentation/Breakingchanges/Index.rst @@ -18,6 +18,13 @@ Breaking changes ---------------- +Version 8.0.0 +~~~~~~~~~~~~~ + +This version contains several breaking changes. Make sure to read the changelog, which also contains +important information about those changes: https://github.com/derhansen/sf_banners/releases/tag/8.0.0 + + Version 7.1.0 ~~~~~~~~~~~~~ diff --git a/Documentation/Introduction/Screenshots/Images.txt b/Documentation/Introduction/Screenshots/Images.txt deleted file mode 100755 index 24d63fdb..00000000 --- a/Documentation/Introduction/Screenshots/Images.txt +++ /dev/null @@ -1,6 +0,0 @@ -.. |img-3| image:: ../../Images/sf_banners.png - :height: 783 - :width: 498 -.. :align: left -.. :border: 0 -.. :name: Grafik1 diff --git a/Documentation/Introduction/Screenshots/Index.rst b/Documentation/Introduction/Screenshots/Index.rst index 7574836a..3b3ddc6c 100755 --- a/Documentation/Introduction/Screenshots/Index.rst +++ b/Documentation/Introduction/Screenshots/Index.rst @@ -18,5 +18,7 @@ Screenshots ^^^^^^^^^^^ -|img-3| +.. figure:: /Images/sf_banners.png + :alt: Banner plugin in TYPO3 backend + :class: with-shadow diff --git a/Documentation/Settings.cfg b/Documentation/Settings.cfg deleted file mode 100644 index 275309c6..00000000 --- a/Documentation/Settings.cfg +++ /dev/null @@ -1,73 +0,0 @@ -# coding: utf-8 - -# ##### -# -# Settings.cfg - A TYPO3 Documentation Project's Configuration File -# Information about Settings.cfg: -# https://docs.typo3.org/typo3cms/HowToDocument/GeneralConventions/DirectoryFilenames.html#settings-cfg -# -# About Syntax: -# See https://docs.python.org/2/library/configparser.html -# -# Attention: -# Only " ;" can start an inline comment. -# This is: blank PLUS semicolon! -# -# ##### - -[general] - -project = Banner-Management -version = 5.0 -release = 5.0.0 -t3author = Torben Hansen -copyright = 2013 - 2020 by Torben Hansen - -description = Official documentation for the TYPO3 Extension "Banner Management" - -[html_theme_options] - -; for theme t3SphinxThemeRtd - -#### NOTE: Fill in YOUR values in the following! - -github_branch = master -github_repository = derhansen/sf_banners - -# usually an email address -project_contact = mailto:torben@derhansen.com - -# URL of online discussions, you can leave this blank -project_discussions = - -# URL of webpage of your extension (if it has one) -project_home = https://github.com/derhansen/sf_banners - -# URL to Issues -project_issues = https://github.com/derhansen/sf_banners/issues - -# URL of repository -project_repository = https://github.com/derhansen/sf_banners - -# just leave this blank -use_opensearch = - - -[intersphinx_mapping] - -; Comment out what you don't use. -; Uncomment only what you actually use in crossreferencing! - -# h2document = https://docs.typo3.org/m/typo3/docs-how-to-document/master/en-us/ -# t3coreapi = https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ -# t3editors = https://docs.typo3.org/m/typo3/tutorial-editors/master/en-us/ -# t3extbasebook = https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/Index.html -# t3install = https://docs.typo3.org/m/typo3/guide-installation/master/en-us/ -# t3l10n = https://docs.typo3.org/m/typo3/guide-frontendlocalization/master/en-us/ -# t3start = https://docs.typo3.org/m/typo3/tutorial-getting-started/master/en-us/ -# t3sitepackage = https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/ -# t3tca = https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ -# t3templating = https://docs.typo3.org/m/typo3/tutorial-templating-with-fluid/master/en-us/ -# t3ts45 = https://docs.typo3.org/m/typo3/tutorial-typoscript-in-45-minutes/master/en-us/ -# t3tsconfig = https://docs.typo3.org/m/typo3/reference-tsconfig/master/en-us/ -# t3tsref = https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ \ No newline at end of file diff --git a/Documentation/UsersManual/Installation/Index.rst b/Documentation/UsersManual/Installation/Index.rst index 1639e543..7a99f9e4 100644 --- a/Documentation/UsersManual/Installation/Index.rst +++ b/Documentation/UsersManual/Installation/Index.rst @@ -33,5 +33,5 @@ following: displaymode you want to use. Next select the desired startingpoint (system folder created in step 3) and/or categories. -#. For TYPO3 9.5+ LTS make sure to configure the mapping for the PageType Route Enhancer properly +#. Make sure to configure the mapping for the PageType Route Enhancer properly (see :ref:`routing`), so the extension is able to fetch Banners and count Clicks. diff --git a/Documentation/UsersManual/SettingsForBanners/Index.rst b/Documentation/UsersManual/SettingsForBanners/Index.rst index a2ce5107..6fdf1d5a 100644 --- a/Documentation/UsersManual/SettingsForBanners/Index.rst +++ b/Documentation/UsersManual/SettingsForBanners/Index.rst @@ -28,7 +28,7 @@ The title of the banner. Type """" -Image or HTML. Note, that the type :php`:html` is only available for admin users. If non-admin users should be +Image or HTML. Note, that the type :php:`html` is only available for admin users. If non-admin users should be able to create HTML banners, the extension setting :php:`allowHtmlBannerForNonAdmins` must be enabled. .. warning:: diff --git a/Documentation/guides.xml b/Documentation/guides.xml new file mode 100644 index 00000000..b6b316f9 --- /dev/null +++ b/Documentation/guides.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e4842089 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: help +help: ## Displays this list of targets with descriptions + @echo "The following commands are available:\n" + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: docs +docs: ## Generate projects docs (from "Documentation" directory) + mkdir -p Documentation-GENERATED-temp + + docker run --rm --pull always -v "$(shell pwd)":/project -t ghcr.io/typo3-documentation/render-guides:latest --config=Documentation + +.PHONY: test-docs +test-docs: ## Test the documentation rendering + mkdir -p Documentation-GENERATED-temp + + docker run --rm --pull always -v "$(shell pwd)":/project -t ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --fail-on-log diff --git a/README.md b/README.md index c98ab399..5963cc88 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ TYPO3 extension sf_banner: Banner-Management ## What is it? **Banner-Management** is a banner management extension for TYPO3. It is based of Extbase and Fluid and supports TYPO3 -12.4 LTS. Banners are loaded asynchronously so the page load time is affected as less as possible. +all TYPO3 versions >= 6.2. Banners are loaded asynchronously so the page load time is affected as less as possible. ## What does it do? @@ -29,8 +29,9 @@ uses JavaScript (AJAX) to load all banners and postscribe.js to place the banner | Version | TYPO3 | PHP | Support/Development | |---------|------------|-----------|--------------------------------------| +| 8.x | 13.4 | >= 8.1 | Features, Bugfixes, Security Updates | | 7.x | 12.4 | >= 8.1 | Features, Bugfixes, Security Updates | -| 6.x | 11.5 | 7.4 - 8.1 | Features, Bugfixes, Security Updates | +| 6.x | 11.5 | 7.4 - 8.1 | Bugfixes, Security Updates | | 5.x | 9.5 - 10.4 | 7.2 - 7.4 | Security Updates | | 4.x | 8.7 - 9.5 | 7.0 - 7.4 | Not supported any more | | 3.x | 7.5 - 9.5 | 5.6 - 7.2 | Not supported any more | diff --git a/Tests/Functional/Repository/BannerRepositoryTest.php b/Tests/Functional/Repository/BannerRepositoryTest.php index d383c8e9..f22df53e 100644 --- a/Tests/Functional/Repository/BannerRepositoryTest.php +++ b/Tests/Functional/Repository/BannerRepositoryTest.php @@ -13,6 +13,9 @@ use DERHANSEN\SfBanners\Domain\Model\Dto\BannerDemand; use DERHANSEN\SfBanners\Domain\Repository\BannerRepository; +use PHPUnit\Framework\Attributes\Test; +use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; +use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; class BannerRepositoryTest extends FunctionalTestCase @@ -24,6 +27,8 @@ public function setUp(): void { parent::setUp(); $this->bannerRepository = $this->getContainer()->get(BannerRepository::class); + $request = (new ServerRequest())->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE); + $GLOBALS['TYPO3_REQUEST'] = $request; $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_category.csv'); $this->importCSVDataSet(__DIR__ . '/../Fixtures/pages.csv'); @@ -32,9 +37,8 @@ public function setUp(): void /** * Test if records are returned correctly with given startingpoints - * - * @test */ + #[Test] public function findRecordsByStartingPointTest(): void { $demand = new BannerDemand(); @@ -54,9 +58,8 @@ public function findRecordsByStartingPointTest(): void /** * Test if records are found by their catagory - * - * @test */ + #[Test] public function findRecordsByCategoryTest(): void { $demand = new BannerDemand(); @@ -83,9 +86,8 @@ public function findRecordsByCategoryTest(): void /** * Test is records are found by their displaymode - * - * @test */ + #[Test] public function findRecordsWithDisplayModeTest(): void { $demand = new BannerDemand(); @@ -143,9 +145,8 @@ public function findRecordsWithDisplayModeTest(): void /** * Test if records are not returned on pages where they not should be shown - * - * @test */ + #[Test] public function findRecordsForSpecialExcludePageUidTest(): void { $demand = new BannerDemand(); @@ -178,9 +179,8 @@ public function findRecordsForSpecialExcludePageUidTest(): void /** * Test if records are not returned on pages recursively where they not should be shown - * - * @test */ + #[Test] public function findRecordsForSpecialExcludeRecursivePageUidTest(): void { $demand = new BannerDemand(); @@ -214,9 +214,8 @@ public function findRecordsForSpecialExcludeRecursivePageUidTest(): void /** * Test if records are not returned, if max impressions reached - * - * @test */ + #[Test] public function findRecordsWithMaxImpressionsTest(): void { $demand = new BannerDemand(); @@ -231,9 +230,8 @@ public function findRecordsWithMaxImpressionsTest(): void /** * Test if records are not returned, if max clicks reached - * - * @test */ + #[Test] public function findRecordsWithMaxClicksTest(): void { $demand = new BannerDemand(); @@ -248,9 +246,8 @@ public function findRecordsWithMaxClicksTest(): void /** * Test if records are not returned, if max clicks and/or max impressions reached - * - * @test */ + #[Test] public function findRecordsWithMaxImpressionsAndMaxClicksTest(): void { $demand = new BannerDemand(); @@ -265,9 +262,8 @@ public function findRecordsWithMaxImpressionsAndMaxClicksTest(): void /** * Test if expected amount of records are returned, if a mex result is set - * - * @test */ + #[Test] public function findRecordsWithMaxResultsTest(): void { $demand = new BannerDemand(); diff --git a/Tests/Unit/Domain/Model/BannerDemandTest.php b/Tests/Unit/Domain/Model/BannerDemandTest.php index 35513fe5..ea776ecd 100644 --- a/Tests/Unit/Domain/Model/BannerDemandTest.php +++ b/Tests/Unit/Domain/Model/BannerDemandTest.php @@ -12,6 +12,7 @@ namespace DERHANSEN\SfBanners\Test\Unit\Domain\Model; use DERHANSEN\SfBanners\Domain\Model\Dto\BannerDemand; +use PHPUnit\Framework\Attributes\Test; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; class BannerDemandTest extends UnitTestCase @@ -28,9 +29,7 @@ public function tearDown(): void unset($this->fixture); } - /** - * @test - */ + #[Test] public function categoriesCanBeSetTest(): void { $categories = '1,2,3,4'; @@ -38,9 +37,7 @@ public function categoriesCanBeSetTest(): void self::assertEquals($categories, $this->fixture->getCategories()); } - /** - * @test - */ + #[Test] public function startingPointCanBeSetTest(): void { $startingPoint = '1'; @@ -48,17 +45,13 @@ public function startingPointCanBeSetTest(): void self::assertEquals($startingPoint, $this->fixture->getStartingPoint()); } - /** - * @test - */ + #[Test] public function displayModeReturnsInitialValueForDisplayModeTest(): void { self::assertEquals('all', $this->fixture->getDisplayMode()); } - /** - * @test - */ + #[Test] public function displayModeCanBeSetTest(): void { $displayMode = 'allRandom'; @@ -66,9 +59,7 @@ public function displayModeCanBeSetTest(): void self::assertEquals($displayMode, $this->fixture->getDisplayMode()); } - /** - * @test - */ + #[Test] public function currentPageUidCanBeSetTest(): void { $currentPageUid = 99; @@ -76,17 +67,13 @@ public function currentPageUidCanBeSetTest(): void self::assertEquals($currentPageUid, $this->fixture->getCurrentPageUid()); } - /** - * @test - */ + #[Test] public function getMaxResultsReturnsInitialValue(): void { self::assertEquals(0, $this->fixture->getMaxResults()); } - /** - * @test - */ + #[Test] public function maxResultsCanBeSet(): void { $this->fixture->setMaxResults(10); diff --git a/Tests/Unit/Domain/Model/BannerTest.php b/Tests/Unit/Domain/Model/BannerTest.php index edba1a43..f0db23d5 100644 --- a/Tests/Unit/Domain/Model/BannerTest.php +++ b/Tests/Unit/Domain/Model/BannerTest.php @@ -13,6 +13,7 @@ use DERHANSEN\SfBanners\Domain\Model\Banner; use DERHANSEN\SfBanners\Domain\Model\Page; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Extbase\Domain\Model\Category; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; @@ -32,9 +33,7 @@ public function tearDown(): void unset($this->fixture); } - /** - * @test - */ + #[Test] public function titleCanBeSetTest(): void { $title = 'a title'; @@ -42,9 +41,7 @@ public function titleCanBeSetTest(): void self::assertEquals($title, $this->fixture->getTitle()); } - /** - * @test - */ + #[Test] public function descriptionCanBeSetTest(): void { $description = 'a description'; @@ -52,9 +49,7 @@ public function descriptionCanBeSetTest(): void self::assertEquals($description, $this->fixture->getDescription()); } - /** - * @test - */ + #[Test] public function typeCanBeSetTest(): void { $type = 0; @@ -62,9 +57,7 @@ public function typeCanBeSetTest(): void self::assertEquals($type, $this->fixture->getType()); } - /** - * @test - */ + #[Test] public function getLinkRespectsFalMediaSetting(): void { $mockFile = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\FileReference::class) @@ -83,9 +76,7 @@ public function getLinkRespectsFalMediaSetting(): void self::assertEquals('https://www.typo3.org', $this->fixture->getLink()); } - /** - * @test - */ + #[Test] public function htmlCanBeSetTest(): void { $html = '

test

'; @@ -93,9 +84,7 @@ public function htmlCanBeSetTest(): void self::assertEquals($html, $this->fixture->getHtml()); } - /** - * @test - */ + #[Test] public function impressionsMaxCanBeSetTest(): void { $impressionsMax = 100; @@ -103,9 +92,7 @@ public function impressionsMaxCanBeSetTest(): void self::assertEquals($impressionsMax, $this->fixture->getImpressionsMax()); } - /** - * @test - */ + #[Test] public function clicksMaxCanBeSetTest(): void { $clicksMax = 100; @@ -113,9 +100,7 @@ public function clicksMaxCanBeSetTest(): void self::assertEquals($clicksMax, $this->fixture->getClicksMax()); } - /** - * @test - */ + #[Test] public function impressionsCanBeSetTest(): void { $impressions = 100; @@ -123,9 +108,7 @@ public function impressionsCanBeSetTest(): void self::assertEquals($impressions, $this->fixture->getImpressions()); } - /** - * @test - */ + #[Test] public function clicksCanBeSetTest(): void { $clicks = 100; @@ -133,18 +116,14 @@ public function clicksCanBeSetTest(): void self::assertEquals($clicks, $this->fixture->getClicks()); } - /** - * @test - */ + #[Test] public function recursiveCanBeSet(): void { $this->fixture->setRecursive(true); self::assertTrue($this->fixture->getRecursive()); } - /** - * @test - */ + #[Test] public function getCategoryReturnsInitialValueForCategory(): void { $newObjectStorage = new ObjectStorage(); @@ -154,9 +133,7 @@ public function getCategoryReturnsInitialValueForCategory(): void ); } - /** - * @test - */ + #[Test] public function setCategoryForObjectStorageContainingCategorySetsCategory(): void { $category = new Category(); @@ -166,9 +143,7 @@ public function setCategoryForObjectStorageContainingCategorySetsCategory(): voi self::assertEquals($objectStorageHoldingExactlyOneCategory, $this->fixture->getCategory()); } - /** - * @test - */ + #[Test] public function addCategoryToObjectStorageHoldingCategory(): void { $category = new Category(); @@ -178,9 +153,7 @@ public function addCategoryToObjectStorageHoldingCategory(): void $this->fixture->addCategory($category); } - /** - * @test - */ + #[Test] public function removeCategoryFromObjectStorageHoldingCategory(): void { $category = new Category(); @@ -190,9 +163,7 @@ public function removeCategoryFromObjectStorageHoldingCategory(): void $this->fixture->removeCategory($category); } - /** - * @test - */ + #[Test] public function getExcludePagesReturnsInitialValueForExcudePages(): void { $newObjectStorage = new ObjectStorage(); @@ -202,9 +173,7 @@ public function getExcludePagesReturnsInitialValueForExcudePages(): void ); } - /** - * @test - */ + #[Test] public function setExcludePagesForObjectStorageContainingExcludePagesSetsExcludePages(): void { $page = new Page(); @@ -214,9 +183,7 @@ public function setExcludePagesForObjectStorageContainingExcludePagesSetsExclude self::assertEquals($objectStorageHoldingExactlyOnePage, $this->fixture->getExcludepages()); } - /** - * @test - */ + #[Test] public function addExludePagesToObjectStorageHoldingExcludePages(): void { $page = new Page(); @@ -226,9 +193,7 @@ public function addExludePagesToObjectStorageHoldingExcludePages(): void $this->fixture->addExcludepages($page); } - /** - * @test - */ + #[Test] public function removeExludePagesFromObjectStorageHoldingExcludePages(): void { $page = new Page(); @@ -238,9 +203,7 @@ public function removeExludePagesFromObjectStorageHoldingExcludePages(): void $this->fixture->removeExcludepages($page); } - /** - * @test - */ + #[Test] public function getAssetsReturnsInitialValueForAsset(): void { $newObjectStorage = new ObjectStorage(); @@ -250,9 +213,7 @@ public function getAssetsReturnsInitialValueForAsset(): void ); } - /** - * @test - */ + #[Test] public function setAssetForObjectStorageContainingAssetSetsAsset(): void { $file = new FileReference(); @@ -262,9 +223,7 @@ public function setAssetForObjectStorageContainingAssetSetsAsset(): void self::assertEquals($objectStorageHoldingExactlyOneFile, $this->fixture->getAssets()); } - /** - * @test - */ + #[Test] public function addAssetToObjectStorageHoldingAsses(): void { $file = new FileReference(); @@ -274,9 +233,7 @@ public function addAssetToObjectStorageHoldingAsses(): void $this->fixture->addAsset($file); } - /** - * @test - */ + #[Test] public function removeAssetFromObjectStorageHoldingAsset(): void { $file = new FileReference(); diff --git a/composer.json b/composer.json index cd6ca213..d09be93b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "GPL-2.0-or-later" ], "require": { - "typo3/cms-core": "^12.4" + "typo3/cms-core": "^13.4" }, "autoload": { "psr-4": { diff --git a/ext_emconf.php b/ext_emconf.php index 6e7f47b7..ea67750a 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -19,10 +19,10 @@ 'state' => 'stable', 'uploadfolder' => 1, 'clearCacheOnLoad' => 0, - 'version' => '7.1.0', + 'version' => '8.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '12.4.0-12.4.99', + 'typo3' => '13.4.0-13.4.99', ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index 7a8e3057..eb6937a8 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,25 +2,26 @@ defined('TYPO3') or die(); +use DERHANSEN\SfBanners\Controller\BannerController; use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend; use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend; +use TYPO3\CMS\Extbase\Utility\ExtensionUtility; -call_user_func(function () { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'sf_banners', - 'Pi1', - [ - \DERHANSEN\SfBanners\Controller\BannerController::class => 'show,getBanners,click', - ], - /* non-cacheable actions */ - [ - \DERHANSEN\SfBanners\Controller\BannerController::class => 'getBanners,click', - ] - ); +ExtensionUtility::configurePlugin( + 'sf_banners', + 'Pi1', + [ + BannerController::class => 'show,getBanners,click', + ], + /* non-cacheable actions */ + [ + BannerController::class => 'getBanners,click', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); - // Register cache 'sfbanners_cache' - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache'] ??= []; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['frontend'] ??= VariableFrontend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['backend'] ??= Typo3DatabaseBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['groups'] ??= ['pages', 'all']; -}); +// Register cache 'sfbanners_cache' +$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache'] ??= []; +$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['frontend'] ??= VariableFrontend::class; +$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['backend'] ??= Typo3DatabaseBackend::class; +$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['groups'] ??= ['pages', 'all']; diff --git a/ext_tables.sql b/ext_tables.sql deleted file mode 100644 index 9f96d493..00000000 --- a/ext_tables.sql +++ /dev/null @@ -1,59 +0,0 @@ -# -# Table structure for table 'tx_sfbanners_domain_model_banner' -# -CREATE TABLE tx_sfbanners_domain_model_banner ( - title varchar(255) DEFAULT '' NOT NULL, - description varchar(255) DEFAULT '' NOT NULL, - type int(11) DEFAULT '0' NOT NULL, - category int(11) DEFAULT '0' NOT NULL, - assets int(11) DEFAULT '0' NOT NULL, - html text, - impressions_max int(11) DEFAULT '0' NOT NULL, - clicks_max int(11) DEFAULT '0' NOT NULL, - impressions int(11) DEFAULT '0' NOT NULL, - clicks int(11) DEFAULT '0' NOT NULL, - excludepages int(11) DEFAULT '0' NOT NULL, - recursive tinyint(4) unsigned DEFAULT '0' NOT NULL, -); - -# -# Table structure for table 'tx_sfbanners_domain_model_banner_excludepages_mm' -# -# -CREATE TABLE tx_sfbanners_domain_model_banner_excludepages_mm ( - uid_local int(11) DEFAULT '0' NOT NULL, - uid_foreign int(11) DEFAULT '0' NOT NULL, - tablenames varchar(30) DEFAULT '' NOT NULL, - sorting int(11) DEFAULT '0' NOT NULL, - - is_dummy_record tinyint(1) unsigned DEFAULT '0' NOT NULL, - - KEY uid_local (uid_local), - KEY uid_foreign (uid_foreign) -); - -# -# TABLE STRUCTURE FOR TABLE 'cf_sfbanners_cache' -# -CREATE TABLE cf_sfbanners_cache ( - id int(11) unsigned NOT NULL auto_increment, - identifier varchar(250) DEFAULT '' NOT NULL, - expires int(11) unsigned DEFAULT '0' NOT NULL, - crdate int(11) unsigned DEFAULT '0' NOT NULL, - content mediumblob, - lifetime int(11) unsigned DEFAULT '0' NOT NULL, - PRIMARY KEY (id), - KEY cache_id (identifier) -) ENGINE=InnoDB; - -# -# TABLE STRUCTURE FOR TABLE 'cf_sfbanners_cache_tags' -# -CREATE TABLE cf_sfbanners_cache_tags ( - id int(11) unsigned NOT NULL auto_increment, - identifier varchar(250) DEFAULT '' NOT NULL, - tag varchar(250) DEFAULT '' NOT NULL, - PRIMARY KEY (id), - KEY cache_id (identifier), - KEY cache_tag (tag) -) ENGINE=InnoDB; \ No newline at end of file