From 2f8c4b03e39e307c6a1c173ecbd420689f05dad0 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 8 Mar 2023 20:52:07 +0100 Subject: [PATCH] Support of TYPO3 v12 (#2022) --- .github/workflows/ci.yml | 81 --- .github/workflows/core11.yml | 55 ++ .github/workflows/core12.yml | 49 ++ .gitignore | 10 +- .styleci.yml | 1 + Build/.php_cs | 76 --- Build/FunctionalTests.xml | 34 -- Build/Local/FunctionalTests.xml | 34 -- Build/Local/phpunit.xml | 27 - Build/Scripts/runTests.sh | 482 +++++++++++++++ Build/UnitTests.xml | 28 - Build/php-cs-fixer/php-cs-fixer.php | 76 +++ Build/phpunit/FunctionalTests.xml | 52 ++ .../phpunit}/FunctionalTestsBootstrap.php | 0 Build/phpunit/UnitTests.xml | 45 ++ .../phpunit}/UnitTestsBootstrap.php | 2 +- Build/testing-docker/docker-compose.yml | 427 ++++++++++++++ .../NewsFlexFormManipulation.php | 282 --------- .../FormDataProvider/NewsRowInitializeNew.php | 6 +- Classes/Backend/FormEngine/SlugPrefix.php | 10 +- .../RecordList/NewsDatabaseRecordList.php | 8 +- .../RecordList/RecordListConstraint.php | 27 +- Classes/Command/ProxyClassRebuildCommand.php | 2 +- .../Controller/AdministrationController.php | 18 +- Classes/Controller/CategoryController.php | 19 +- Classes/Controller/ImportController.php | 160 ----- Classes/Controller/NewsBaseController.php | 110 +--- Classes/Controller/NewsController.php | 96 ++- Classes/Controller/TagController.php | 21 +- .../DataProcessing/AddNewsToMenuProcessor.php | 22 +- .../DisableLanguageMenuProcessor.php | 14 +- Classes/Database/QueryGenerator.php | 72 +++ Classes/Domain/Model/Category.php | 14 +- Classes/Domain/Model/DemandInterface.php | 6 +- Classes/Domain/Model/Dto/EmConfiguration.php | 36 +- Classes/Domain/Model/Dto/NewsDemand.php | 15 +- Classes/Domain/Model/Dto/Search.php | 20 +- Classes/Domain/Model/FileReference.php | 18 +- Classes/Domain/Model/Link.php | 29 +- Classes/Domain/Model/News.php | 123 +--- Classes/Domain/Model/NewsDefault.php | 6 +- Classes/Domain/Model/NewsExternal.php | 6 +- Classes/Domain/Model/NewsInternal.php | 6 +- Classes/Domain/Model/Tag.php | 31 +- Classes/Domain/Model/TtContent.php | 62 +- .../Repository/AbstractDemandedRepository.php | 31 +- .../Repository/AdministrationRepository.php | 11 +- .../Domain/Repository/CategoryRepository.php | 17 +- .../DemandedRepositoryInterface.php | 7 +- Classes/Domain/Repository/FileRepository.php | 11 +- Classes/Domain/Repository/LinkRepository.php | 11 +- Classes/Domain/Repository/MediaRepository.php | 11 +- .../Repository/NewsDefaultRepository.php | 6 +- Classes/Domain/Repository/NewsRepository.php | 87 +-- Classes/Domain/Repository/TagRepository.php | 7 +- .../Domain/Repository/TtContentRepository.php | 11 +- .../Domain/Service/AbstractImportService.php | 38 +- .../Domain/Service/CategoryImportService.php | 23 +- Classes/Domain/Service/NewsImportService.php | 22 +- .../Event/CategoryImportPostHydrateEvent.php | 13 +- Classes/Event/CategoryListActionEvent.php | 13 +- ...fyDatabaseQueryForContentEventListener.php | 79 +++ ...difyFileReferenceControlsEventListener.php | 50 ++ .../Event/ModifyCacheTagsFromDemandEvent.php | 11 +- .../Event/ModifyCacheTagsFromNewsEvent.php | 11 +- ...dOfNewsRecordFailedInDetailActionEvent.php | 13 +- Classes/Event/NewsDateMenuActionEvent.php | 13 +- Classes/Event/NewsDetailActionEvent.php | 13 +- Classes/Event/NewsImportPostHydrateEvent.php | 13 +- Classes/Event/NewsImportPreHydrateEvent.php | 11 +- Classes/Event/NewsListActionEvent.php | 13 +- Classes/Event/NewsListSelectedActionEvent.php | 13 +- Classes/Event/NewsPostImportEvent.php | 11 +- Classes/Event/NewsPreImportEvent.php | 11 +- Classes/Event/NewsSearchFormActionEvent.php | 13 +- Classes/Event/NewsSearchResultActionEvent.php | 13 +- Classes/Event/TagListActionEvent.php | 13 +- Classes/Hooks/Backend/PageViewQueryHook.php | 9 +- Classes/Hooks/Backend/RecordListQueryHook.php | 10 +- Classes/Hooks/DataHandlerHook.php | 16 +- Classes/Hooks/FlexformHook.php | 290 --------- Classes/Hooks/InlineElementHook.php | 17 +- Classes/Hooks/ItemsProcFunc.php | 71 +-- Classes/Hooks/Labels.php | 9 +- ...youtView.php => PluginPreviewRenderer.php} | 426 ++++---------- Classes/Jobs/AbstractImportJob.php | 8 +- Classes/Jobs/ImportJobInterface.php | 6 +- .../Pagination/CustomAbstractPaginator.php | 2 +- Classes/Pagination/QueryResultPaginator.php | 2 +- Classes/Seo/HrefLangEvent.php | 6 +- Classes/Seo/NewsAvailability.php | 32 +- Classes/Seo/NewsTitleProvider.php | 6 +- Classes/Seo/NewsXmlSitemapDataProvider.php | 24 +- Classes/Service/AccessControlService.php | 15 +- Classes/Service/CategoryService.php | 17 +- .../Import/DataProviderServiceInterface.php | 6 +- .../Service/LinkHandlerTargetPageService.php | 15 +- Classes/Service/SettingsService.php | 15 +- Classes/Service/SlugService.php | 98 ++-- .../TreeProvider/DatabaseTreeDataProvider.php | 127 +--- Classes/Updates/NewsSlugUpdater.php | 9 +- Classes/Updates/PluginPermissionUpdater.php | 124 ++++ Classes/Updates/PluginUpdater.php | 244 ++++++++ Classes/Updates/PopulateCategorySlugs.php | 27 +- Classes/Updates/PopulateTagSlugs.php | 24 +- .../Updates/RealurlAliasNewsSlugUpdater.php | 9 +- Classes/Updates/RelatedLinkIntegerDefault.php | 14 +- Classes/Updates/TitleFieldDefault.php | 14 +- Classes/Utility/Cache.php | 20 +- Classes/Utility/ClassCacheManager.php | 6 +- Classes/Utility/ClassLoader.php | 18 +- Classes/Utility/ClassParser.php | 11 +- Classes/Utility/ConstraintHelper.php | 7 +- Classes/Utility/ImportJob.php | 13 +- Classes/Utility/Page.php | 22 +- Classes/Utility/TemplateLayout.php | 7 +- Classes/Utility/TypoScript.php | 10 +- Classes/Utility/Validation.php | 7 +- .../Be/IsCheckboxActiveViewHelper.php | 7 +- .../ViewHelpers/Category/CountViewHelper.php | 19 +- .../PageAvailableInLanguageViewHelper.php | 6 +- .../ExcludeDisplayedNewsViewHelper.php | 12 +- .../ViewHelpers/ExtensionLoadedViewHelper.php | 18 +- .../ViewHelpers/Format/NothingViewHelper.php | 13 +- Classes/ViewHelpers/HeaderDataViewHelper.php | 9 +- Classes/ViewHelpers/IfIsActiveViewHelper.php | 7 +- Classes/ViewHelpers/ImageSizeViewHelper.php | 14 +- Classes/ViewHelpers/IncludeFileViewHelper.php | 88 --- .../ViewHelpers/Iterator/ChunkViewHelper.php | 14 +- Classes/ViewHelpers/LinkViewHelper.php | 31 +- Classes/ViewHelpers/MetaTagViewHelper.php | 7 +- .../MultiCategoryLink/ArgumentsViewHelper.php | 26 +- .../IsCategoryActiveViewHelper.php | 7 +- .../PaginateBodytextViewHelper.php | 12 +- .../ViewHelpers/RemoveMediaTagsViewHelper.php | 7 +- Classes/ViewHelpers/RenderMediaViewHelper.php | 13 +- Classes/ViewHelpers/SearchFormViewHelper.php | 4 +- .../ViewHelpers/SimplePrevNextViewHelper.php | 23 +- Classes/ViewHelpers/Tag/CountViewHelper.php | 17 +- Classes/ViewHelpers/TargetLinkViewHelper.php | 6 +- Classes/ViewHelpers/TitleTagViewHelper.php | 8 +- Classes/Xclass/ExtensionServiceXclassed.php | 76 +++ .../Xclass/InlineRecordContainerForNews.php | 105 ---- Configuration/Extbase/Persistence/Classes.php | 12 +- .../FlexForms/flexform_category_list.xml | 185 ++++++ .../FlexForms/flexform_news_date_menu.xml | 375 ++++++++++++ .../FlexForms/flexform_news_detail.xml | 242 ++++++++ .../FlexForms/flexform_news_list.xml | 552 ++++++++++++++++++ .../FlexForms/flexform_news_search_form.xml | 83 +++ .../FlexForms/flexform_news_selected_list.xml | 315 ++++++++++ Configuration/FlexForms/flexform_tag_list.xml | 233 ++++++++ Configuration/Icons.php | 33 ++ Configuration/Services.php | 6 +- Configuration/Services.yaml | 14 + Configuration/TCA/Overrides/pages.php | 6 +- Configuration/TCA/Overrides/sys_category.php | 95 +-- .../TCA/Overrides/sys_file_reference.php | 6 +- Configuration/TCA/Overrides/sys_reaction.php | 13 + Configuration/TCA/Overrides/sys_template.php | 2 +- Configuration/TCA/Overrides/tt_content.php | 70 ++- .../Overrides/tx_news_domain_model_news.php | 16 +- .../TCA/Overrides/z_misc_11_adoptions.php | 33 -- .../TCA/Overrides/z_misc_12_adoptions.php | 59 ++ .../TCA/tx_news_domain_model_link.php | 57 +- .../TCA/tx_news_domain_model_news.php | 336 ++++++----- .../TCA/tx_news_domain_model_tag.php | 61 +- .../TSconfig/ContentElementWizard.tsconfig | 100 +++- Documentation/Misc/Changelog/11-0-0.rst | 194 ++++++ Documentation/Misc/Changelog/Index.rst | 1 + .../ExtensionConfiguration/Index.rst | 63 +- .../ViewHelpers/IncludeFileViewHelper.rst | 56 -- Documentation/Reference/ViewHelpers/Index.rst | 1 - .../ExtendNews/AddCustomType/Index.rst | 2 +- .../ExtendNews/ExtendFlexforms/Index.rst | 19 - .../ExtendNews/ExtensionBasedOnNews/Index.rst | 12 +- .../Tutorials/ExtendNews/Hooks/Index.rst | 4 +- .../ExtendNews/ProxyClassGenerator/Index.rst | 4 +- README.md | 8 +- Resources/Private/Language/locallang_be.xlf | 419 +++++++------ Resources/Private/Layouts/Detail.html | 2 +- Resources/Private/Layouts/General.html | 2 +- Resources/Public/Icons/module_import.svg | 1 - .../Public/Icons/plugin-category-menu.svg | 35 ++ Resources/Public/Icons/plugin-date-menu.svg | 28 + Resources/Public/Icons/plugin-detail.svg | 25 + .../Public/Icons/plugin-list-with-detail.svg | 19 + Resources/Public/Icons/plugin-list.svg | 24 + Resources/Public/Icons/plugin-search-form.svg | 21 + .../Public/Icons/plugin-search-results.svg | 22 + .../Public/Icons/plugin-selected-list.svg | 29 + Resources/Public/Icons/plugin-tag-menu.svg | 43 ++ Resources/Public/Icons/plugin_wizard.svg | 1 - Tests/Build/FunctionalTests.xml | 24 - Tests/Build/UnitTests.xml | 24 - .../Controller/NewsControllerTest.php | 161 ----- .../Fixtures/TypoScript/setup.typoscript | 38 +- Tests/Functional/Fixtures/sys_category.csv | 3 + Tests/Functional/Fixtures/sys_category.xml | 15 - Tests/Functional/Fixtures/tags.csv | 25 + Tests/Functional/Fixtures/tags.xml | 32 - .../Fixtures/tx_news_domain_model_news.csv | 38 ++ .../Fixtures/tx_news_domain_model_news.xml | 251 -------- .../Pagination/QueryResultPaginatorTest.php | 18 +- .../Repository/CategoryRepositoryTest.php | 27 +- .../Repository/NewsRepositoryTest.php | 107 ++-- .../Iterator/ChunkViewHelperTest.php | 14 +- .../SimplePrevNextViewHelperTest.php | 35 +- .../NewsRowInitializeNewTest.php | 38 +- Tests/Unit/Controller/TagControllerTest.php | 41 +- Tests/Unit/Domain/Model/CategoryTest.php | 144 ++--- .../Domain/Model/Dto/EmConfigurationTest.php | 17 +- .../Unit/Domain/Model/Dto/NewsDemandTest.php | 115 +--- Tests/Unit/Domain/Model/Dto/SearchTest.php | 24 +- Tests/Unit/Domain/Model/FileReferenceTest.php | 31 +- Tests/Unit/Domain/Model/LinkTest.php | 28 +- Tests/Unit/Domain/Model/NewsTest.php | 115 ++-- Tests/Unit/Domain/Model/TagTest.php | 21 +- Tests/Unit/Domain/Model/TtContentTest.php | 105 +--- .../Repository/CategoryRepositoryTest.php | 33 +- .../Domain/Repository/NewsRepositoryTest.php | 44 +- ...Test.php => PluginPreviewRendererTest.php} | 93 ++- Tests/Unit/Service/CategoryServiceTest.php | 22 +- Tests/Unit/Utility/ImportJobTest.php | 20 +- Tests/Unit/Utility/TemplateLayoutTest.php | 40 +- Tests/Unit/Utility/TypoScriptTest.php | 128 ++-- Tests/Unit/Utility/ValidationTest.php | 34 +- .../Be/IsCheckboxActiveViewhelperTest.php | 24 +- .../ExcludeDisplayedNewsViewHelperTest.php | 18 +- .../Format/NothingViewHelperTest.php | 13 +- Tests/Unit/ViewHelpers/LinkViewHelperTest.php | 44 +- .../PaginateBodytextViewHelperTest.php | 32 +- .../SimplePrevNextViewHelperTest.php | 30 +- .../ViewHelpers/TargetLinkViewHelperTest.php | 25 +- composer.json | 16 +- ext_conf_template.txt | 9 - ext_emconf.php | 6 +- ext_localconf.php | 170 ++++-- ext_tables.php | 126 ++-- ext_tables.sql | 30 - 239 files changed, 6882 insertions(+), 5205 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/core11.yml create mode 100644 .github/workflows/core12.yml delete mode 100644 Build/.php_cs delete mode 100644 Build/FunctionalTests.xml delete mode 100644 Build/Local/FunctionalTests.xml delete mode 100644 Build/Local/phpunit.xml create mode 100755 Build/Scripts/runTests.sh delete mode 100644 Build/UnitTests.xml create mode 100644 Build/php-cs-fixer/php-cs-fixer.php create mode 100644 Build/phpunit/FunctionalTests.xml rename {Tests/Build => Build/phpunit}/FunctionalTestsBootstrap.php (100%) create mode 100644 Build/phpunit/UnitTests.xml rename {Tests/Build => Build/phpunit}/UnitTestsBootstrap.php (98%) create mode 100644 Build/testing-docker/docker-compose.yml delete mode 100644 Classes/Backend/FormDataProvider/NewsFlexFormManipulation.php delete mode 100644 Classes/Controller/ImportController.php create mode 100644 Classes/Database/QueryGenerator.php create mode 100644 Classes/Event/Listener/ModifyDatabaseQueryForContentEventListener.php create mode 100644 Classes/Event/Listener/ModifyFileReferenceControlsEventListener.php delete mode 100644 Classes/Hooks/FlexformHook.php rename Classes/Hooks/{PageLayoutView.php => PluginPreviewRenderer.php} (61%) create mode 100644 Classes/Updates/PluginPermissionUpdater.php create mode 100644 Classes/Updates/PluginUpdater.php delete mode 100644 Classes/ViewHelpers/IncludeFileViewHelper.php create mode 100644 Classes/Xclass/ExtensionServiceXclassed.php delete mode 100644 Classes/Xclass/InlineRecordContainerForNews.php create mode 100644 Configuration/FlexForms/flexform_category_list.xml create mode 100644 Configuration/FlexForms/flexform_news_date_menu.xml create mode 100644 Configuration/FlexForms/flexform_news_detail.xml create mode 100644 Configuration/FlexForms/flexform_news_list.xml create mode 100644 Configuration/FlexForms/flexform_news_search_form.xml create mode 100644 Configuration/FlexForms/flexform_news_selected_list.xml create mode 100644 Configuration/FlexForms/flexform_tag_list.xml create mode 100644 Configuration/Icons.php create mode 100644 Configuration/TCA/Overrides/sys_reaction.php delete mode 100644 Configuration/TCA/Overrides/z_misc_11_adoptions.php create mode 100644 Configuration/TCA/Overrides/z_misc_12_adoptions.php create mode 100644 Documentation/Misc/Changelog/11-0-0.rst delete mode 100644 Documentation/Reference/ViewHelpers/IncludeFileViewHelper.rst delete mode 100644 Resources/Public/Icons/module_import.svg create mode 100755 Resources/Public/Icons/plugin-category-menu.svg create mode 100755 Resources/Public/Icons/plugin-date-menu.svg create mode 100755 Resources/Public/Icons/plugin-detail.svg create mode 100755 Resources/Public/Icons/plugin-list-with-detail.svg create mode 100755 Resources/Public/Icons/plugin-list.svg create mode 100755 Resources/Public/Icons/plugin-search-form.svg create mode 100755 Resources/Public/Icons/plugin-search-results.svg create mode 100755 Resources/Public/Icons/plugin-selected-list.svg create mode 100755 Resources/Public/Icons/plugin-tag-menu.svg delete mode 100644 Resources/Public/Icons/plugin_wizard.svg delete mode 100644 Tests/Build/FunctionalTests.xml delete mode 100644 Tests/Build/UnitTests.xml delete mode 100644 Tests/Functional/Controller/NewsControllerTest.php create mode 100644 Tests/Functional/Fixtures/sys_category.csv delete mode 100644 Tests/Functional/Fixtures/sys_category.xml create mode 100644 Tests/Functional/Fixtures/tags.csv delete mode 100644 Tests/Functional/Fixtures/tags.xml create mode 100644 Tests/Functional/Fixtures/tx_news_domain_model_news.csv delete mode 100644 Tests/Functional/Fixtures/tx_news_domain_model_news.xml rename Tests/Unit/Hooks/{PageLayoutViewTest.php => PluginPreviewRendererTest.php} (72%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index c6fcad9bd6..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: CI - -on: [ push, pull_request ] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - build: - runs-on: ubuntu-18.04 - - continue-on-error: ${{ matrix.env.experimental == true }} - strategy: - fail-fast: false - matrix: - env: - - { php: 7.4, TYPO3_VERSION: ^10.4, TESTING_FRAMEWORK: ^6.5.0 } - - { php: 7.4, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: ^6.6 } - - { php: 8.0, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: ^6.6 } - - env: ${{ matrix.env }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.env.php }} - tools: composer - extensions: pdo, sqlite3 - - # composer - - name: Update Composer - run: | - sudo composer self-update - composer --version - - name: Validate composer.json and composer.lock - run: composer validate - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache - key: dependencies-composer-${{ hashFiles('composer.json') }} - - - name: Ensure stability dev - if: ${{ matrix.env.TYPO3_VERSION == 'dev-main' }} - run: | - composer config minimum-stability dev - composer config prefer-stable true - - name: Install TYPO3 core - run: composer require typo3/cms-core="${TYPO3_VERSION}" ${PREFER_LOWEST}; - - - name: Install testing framework ${{ matrix.env.TESTING_FRAMEWORK }} - if: ${{ matrix.env.TESTING_FRAMEWORK }} - run: composer require --dev typo3/testing-framework="${TESTING_FRAMEWORK}"; - - - name: Install prophecy trait - if: ${{ matrix.env.TESTING_FRAMEWORK }} - run: composer require --dev phpspec/prophecy-phpunit="^2.0"; - - # unit tests - - name: Unit Tests - run: | - echo "Running ${TYPO3_VERSION} unit tests with $(which php)"; - .Build/bin/phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/; - - # start db - - name: Start MySQL - run: sudo /etc/init.d/mysql start - - # functional tests - - name: Functional Tests - run: | - export typo3DatabaseName="typo3"; - export typo3DatabaseHost="127.0.0.1"; - export typo3DatabaseUsername="root"; - export typo3DatabasePassword="root"; - .Build/bin/phpunit --colors -c Build/FunctionalTests.xml Tests/Functional - - - name: Reset composer.json - run: git checkout composer.json; diff --git a/.github/workflows/core11.yml b/.github/workflows/core11.yml new file mode 100644 index 0000000000..04152ac34b --- /dev/null +++ b/.github/workflows/core11.yml @@ -0,0 +1,55 @@ +name: core 11 + +on: [ push, pull_request ] + +jobs: + tests: + name: v11 + runs-on: ubuntu-20.04 + strategy: + # This prevents cancellation of matrix job runs, if one/two already failed and let the + # rest matrix jobs be executed anyway. + fail-fast: false + matrix: + php: [ '7.4', '8.0', '8.1', '8.2' ] + composerInstall: [ 'composerInstallLowest', 'composerInstallHighest' ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Validate composer.json and composer.lock + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s composer -e 'validate' + + - name: Install testing system + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s ${{ matrix.composerInstall }} + + - name: Lint PHP + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s lint + + - name: Validate code against CGL + run: PHP_CS_FIXER_IGNORE_ENV=1 Build/Scripts/runTests.sh -t 11 -p 8.1 -s cgl -n + + - name: Unit Tests + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -s unit + + - name: Functional Tests with mariadb and mysqli + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -d mariadb -a mysqli -s functional + + - name: Functional Tests with mariadb and pdo_mysql + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -d mariadb -a pdo_mysql -s functional + + - name: Functional Tests with mysql and mysqli + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -d mysql -a mysqli -s functional + + - name: Functional Tests with mysql and pdo_mysql + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -d mysql -a pdo_mysql -s functional + + - name: Functional Tests with postgres + # v11 postgres functional disabled with PHP 8.2 since https://github.com/doctrine/dbal/commit/73eec6d882b99e1e2d2d937accca89c1bd91b2d7 + # is not fixed in doctrine core v11 doctrine 2.13.9 + if: ${{ matrix.php <= '8.1' }} + run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -d postgres -s functional + + # @todo disabled, due cross dbmns issues in code. Should be fixed first + # - name: Functional Tests with sqlite + # run: Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php }} -d sqlite -s functional \ No newline at end of file diff --git a/.github/workflows/core12.yml b/.github/workflows/core12.yml new file mode 100644 index 0000000000..6a39bc10cf --- /dev/null +++ b/.github/workflows/core12.yml @@ -0,0 +1,49 @@ +name: core 12 + +on: [ push, pull_request ] + +jobs: + tests: + name: v12 + runs-on: ubuntu-20.04 + strategy: + # This prevents cancellation of matrix job runs, if one/two already failed and let the + # rest matrix jobs be executed anyway. + fail-fast: false + matrix: + php: [ '8.1', '8.2' ] + composerInstall: [ 'composerInstallLowest', 'composerInstallHighest' ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install testing system + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -s ${{ matrix.composerInstall }} + + - name: Lint PHP + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -s lint + + - name: Validate code against CGL + run: PHP_CS_FIXER_IGNORE_ENV=1 Build/Scripts/runTests.sh -t 12 -p 8.1 -s cgl -n + + - name: Unit Tests + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -s unit + + - name: Functional Tests with mariadb and mysqli + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -d mariadb -a mysqli -s functional + + - name: Functional Tests with mariadb and pdo_mysql + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -d mariadb -a pdo_mysql -s functional + + - name: Functional Tests with mysql and mysqli + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -d mysql -a mysqli -s functional + + - name: Functional Tests with mysql and pdo_mysql + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -d mysql -a pdo_mysql -s functional + + - name: Functional Tests with postgres + run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -d postgres -s functional + + # @todo disabled, due cross dbmns issues in code. Should be fixed first + # - name: Functional Tests with sqlite + # run: Build/Scripts/runTests.sh -t 12 -p ${{ matrix.php }} -d sqlite -s functional \ No newline at end of file diff --git a/.gitignore b/.gitignore index a2dc32652f..5cd31fee60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,16 @@ /.Build -/Build/Local/.phpunit.result.cache +/Build/testing-docker/.env +.cache /composer.lock +/composer.json.testing /.php_cs.cache +/.php-cs-fixer.cache /Documentation-GENERATED-temp /Resources/Private/Templates/News/Month.html /Resources/Private/Templates/Styles/Twb/Templates/News/Month.html /out.txt /Tests/Build/.phpunit.result.cache -.DS_Store \ No newline at end of file +.DS_Store +.idea/ +.fleet/ +/var/ \ No newline at end of file diff --git a/.styleci.yml b/.styleci.yml index dc4780bf6c..7608e8918d 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -23,4 +23,5 @@ finder: - "*.php" not-path: - ".Build" + - "Build/php-cs-fixer" - "Documentation" diff --git a/Build/.php_cs b/Build/.php_cs deleted file mode 100644 index 78191749d5..0000000000 --- a/Build/.php_cs +++ /dev/null @@ -1,76 +0,0 @@ -in(__DIR__ . '/../'); -// Return a Code Sniffing configuration using -// all sniffers needed for PSR-2 -// and additionally: -// - Remove leading slashes in use clauses. -// - PHP single-line arrays should not have trailing comma. -// - Single-line whitespace before closing semicolon are prohibited. -// - Remove unused use statements in the PHP source code -// - Ensure Concatenation to have at least one whitespace around -// - Remove trailing whitespace at the end of blank lines. -return PhpCsFixer\Config::create() - ->setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - 'no_leading_import_slash' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_unused_imports' => true, - 'concat_space' => ['spacing' => 'one'], - 'no_whitespace_in_blank_line' => true, - 'ordered_imports' => true, - 'single_quote' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => true, - 'phpdoc_no_package' => true, - 'phpdoc_scalar' => true, - 'no_blank_lines_after_phpdoc' => true, - 'array_syntax' => ['syntax' => 'short'], - 'whitespace_after_comma_in_array' => true, - 'function_typehint_space' => true, - 'hash_to_slash_comment' => true, - 'no_alias_functions' => true, - 'lowercase_cast' => true, - 'no_leading_namespace_whitespace' => true, - 'native_function_casing' => true, - 'self_accessor' => true, - 'no_short_bool_cast' => true, - 'no_unneeded_control_parentheses' => true - ]) - ->setFinder($finder); diff --git a/Build/FunctionalTests.xml b/Build/FunctionalTests.xml deleted file mode 100644 index a5631f2669..0000000000 --- a/Build/FunctionalTests.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - ../Tests/Functional/ - - - - - ../Classes/ - - - diff --git a/Build/Local/FunctionalTests.xml b/Build/Local/FunctionalTests.xml deleted file mode 100644 index 350cf30f09..0000000000 --- a/Build/Local/FunctionalTests.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - ../../Tests/Functional/ - - - - - ../../Classes/ - - - diff --git a/Build/Local/phpunit.xml b/Build/Local/phpunit.xml deleted file mode 100644 index 6c90e96d6c..0000000000 --- a/Build/Local/phpunit.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - ../../Tests/Unit/ - - - - - ../../Classes/ - - - diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh new file mode 100755 index 0000000000..17caae54aa --- /dev/null +++ b/Build/Scripts/runTests.sh @@ -0,0 +1,482 @@ +#!/usr/bin/env bash + +# +# TYPO3 core test runner based on docker and docker-compose. +# + +# Function to write a .env file in Build/testing-docker +# This is read by docker-compose and vars defined here are +# used in Build/testing-docker/docker-compose.yml +setUpDockerComposeDotEnv() { + # Delete possibly existing local .env file if exists + [ -e .env ] && rm .env + # Set up a new .env file for docker-compose + { + echo "COMPOSE_PROJECT_NAME=${PROJECT_NAME}" + # To prevent access rights of files created by the testing, the docker image later + # runs with the same user that is currently executing the script. docker-compose can't + # use $UID directly itself since it is a shell variable and not an env variable, so + # we have to set it explicitly here. + echo "HOST_UID=`id -u`" + # Your local user + echo "ROOT_DIR=${ROOT_DIR}" + echo "HOST_USER=${USER}" + echo "TEST_FILE=${TEST_FILE}" + echo "TYPO3_VERSION=${TYPO3_VERSION}" + echo "PHP_XDEBUG_ON=${PHP_XDEBUG_ON}" + echo "PHP_XDEBUG_PORT=${PHP_XDEBUG_PORT}" + echo "DOCKER_PHP_IMAGE=${DOCKER_PHP_IMAGE}" + echo "EXTRA_TEST_OPTIONS=${EXTRA_TEST_OPTIONS}" + echo "SCRIPT_VERBOSE=${SCRIPT_VERBOSE}" + echo "CGLCHECK_DRY_RUN=${CGLCHECK_DRY_RUN}" + echo "DATABASE_DRIVER=${DATABASE_DRIVER}" + echo "MARIADB_VERSION=${MARIADB_VERSION}" + echo "MYSQL_VERSION=${MYSQL_VERSION}" + echo "POSTGRES_VERSION=${POSTGRES_VERSION}" + echo "USED_XDEBUG_MODES=${USED_XDEBUG_MODES}" + } > .env +} + +# Options -a and -d depend on each other. The function +# validates input combinations and sets defaults. +handleDbmsAndDriverOptions() { + case ${DBMS} in + mysql|mariadb) + [ -z "${DATABASE_DRIVER}" ] && DATABASE_DRIVER="mysqli" + if [ "${DATABASE_DRIVER}" != "mysqli" ] && [ "${DATABASE_DRIVER}" != "pdo_mysql" ]; then + echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2 + echo >&2 + echo "call \"./Build/Scripts/runTests.sh -h\" to display help and valid options" >&2 + exit 1 + fi + ;; + postgres|sqlite) + if [ -n "${DATABASE_DRIVER}" ]; then + echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2 + echo >&2 + echo "call \"./Build/Scripts/runTests.sh -h\" to display help and valid options" >&2 + exit 1 + fi + ;; + esac +} + +# Load help text into $HELP +read -r -d '' HELP <=20.10 for xdebug break pointing to work reliably, and +a recent docker-compose (tested >=1.21.2) is needed. + +Usage: $0 [options] [file] + +No arguments: Run all unit tests with PHP 7.4 + +Options: + -s <...> + Specifies which test suite to run + - cgl: cgl test and fix all php files + - clean: clean up build and testing related files + - composer: Execute "composer" command, using -e for command arguments pass-through, ex. -e "ci:php:stan" + - composerInstall: "composer update", handy if host has no PHP + - composerInstallLowest: "composer update", handy if host has no PHP + - composerInstallHighest: "composer update", handy if host has no PHP + - functional: functional tests + - lint: PHP linting + - unit: PHP unit tests + + -a + Only with -s acceptance,functional + Specifies to use another driver, following combinations are available: + - mysql + - mysqli (default) + - pdo_mysql + - mariadb + - mysqli (default) + - pdo_mysql + + -d + Only with -s acceptance,functional + Specifies on which DBMS tests are performed + - sqlite: (default) use sqlite + - mariadb: use mariadb + - mysql: use mysql + - postgres: use postgres + + -i <10.2|10.3|10.4|10.5|10.6|10.7> + Only with -d mariadb + Specifies on which version of mariadb tests are performed + - 10.2 (default) + - 10.3 + - 10.4 + - 10.5 + - 10.6 + - 10.7 + + -j <5.5|5.6|5.7|8.0> + Only with -d mysql + Specifies on which version of mysql tests are performed + - 5.5 (default) + - 5.6 + - 5.7 + - 8.0 + + -k <10|11|12|13|14> + Only with -d postgres + Specifies on which version of postgres tests are performed + - 10 (default) + - 11 + - 12 + - 13 + - 14 + + -p <7.4|8.0|8.1|8.2> + Specifies the PHP minor version to be used + - 7.4 (default): use PHP 7.4 + - 8.0: use PHP 8.0 + - 8.1: use PHP 8.1 + - 8.2: use PHP 8.2 + + -t <11|12> + Only with -s composerUpdate + Specifies the TYPO3 core major version to be used + - 11 (default): use TYPO3 core v11 + - 12: use TYPO3 core v12 + + -e "" + Only with -s functional|unit|composer + Additional options to send to phpunit (unit & functional tests) or codeception (acceptance + tests). For phpunit, options starting with "--" must be added after options starting with "-". + Example -e "-v --filter canRetrieveValueWithGP" to enable verbose output AND filter tests + named "canRetrieveValueWithGP" + + -x + Only with -s functional|unit + Send information to host instance for test or system under test break points. This is especially + useful if a local PhpStorm instance is listening on default xdebug port 9003. A different port + can be selected with -y + + -y + Send xdebug information to a different port than default 9003 if an IDE like PhpStorm + is not listening on default port. + + -z + Only with -x and -s functional|unit|acceptance + This sets the used xdebug modes. Defaults to 'debug,develop' + + -n + Only with -s cgl + Activate dry-run in CGL check that does not actively change files and only prints broken ones. + + -u + Update existing typo3/core-testing-*:latest docker images. Maintenance call to docker pull latest + versions of the main php images. The images are updated once in a while and only the youngest + ones are supported by core testing. Use this if weird test errors occur. Also removes obsolete + image versions of typo3/core-testing-*. + + -v + Enable verbose script output. Shows variables and docker commands. + + -h + Show this help. + +Examples: + # Run unit tests using PHP 7.4 + ./Build/Scripts/runTests.sh -s unit +EOF + +# Test if docker-compose exists, else exit out with error +if ! type "docker-compose" > /dev/null; then + echo "This script relies on docker and docker-compose. Please install" >&2 + exit 1 +fi + +# Go to the directory this script is located, so everything else is relative +# to this dir, no matter from where this script is called. +THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +cd "$THIS_SCRIPT_DIR" || exit 1 + +# Go to directory that contains the local docker-compose.yml file +cd ../testing-docker || exit 1 + +# Option defaults +if ! command -v realpath &> /dev/null; then + echo "This script works best with realpath installed" >&2 + ROOT_DIR="${PWD}/../../" +else + ROOT_DIR=`realpath ${PWD}/../../` +fi +TEST_SUITE="" +DBMS="sqlite" +PHP_VERSION="7.4" +TYPO3_VERSION="11" +PHP_XDEBUG_ON=0 +PHP_XDEBUG_PORT=9003 +EXTRA_TEST_OPTIONS="" +SCRIPT_VERBOSE=0 +CGLCHECK_DRY_RUN="" +DATABASE_DRIVER="" +MARIADB_VERSION="10.2" +MYSQL_VERSION="5.5" +POSTGRES_VERSION="10" +USED_XDEBUG_MODES="debug,develop" +#@todo the $$ would add the current process id to the name, keeping as plan b +#PROJECT_NAME="runTests-$(basename $(dirname $ROOT_DIR))-$(basename $ROOT_DIR)-$$" +PROJECT_NAME="runTests-$(basename $(dirname $ROOT_DIR))-$(basename $ROOT_DIR)" +PROJECT_NAME="${PROJECT_NAME//[[:blank:]]/}" +echo $PROJECT_NAME + +# Option parsing +# Reset in case getopts has been used previously in the shell +OPTIND=1 +# Array for invalid options +INVALID_OPTIONS=(); +# Simple option parsing based on getopts (! not getopt) +while getopts ":s:a:d:i:j:k:p:t:e:xy:z:nhuv" OPT; do + case ${OPT} in + s) + TEST_SUITE=${OPTARG} + ;; + a) + DATABASE_DRIVER=${OPTARG} + ;; + d) + DBMS=${OPTARG} + ;; + i) + MARIADB_VERSION=${OPTARG} + if ! [[ ${MARIADB_VERSION} =~ ^(10.2|10.3|10.4|10.5|10.6|10.7)$ ]]; then + INVALID_OPTIONS+=("${OPTARG}") + fi + ;; + j) + MYSQL_VERSION=${OPTARG} + if ! [[ ${MYSQL_VERSION} =~ ^(5.5|5.6|5.7|8.0)$ ]]; then + INVALID_OPTIONS+=("${OPTARG}") + fi + ;; + k) + POSTGRES_VERSION=${OPTARG} + if ! [[ ${POSTGRES_VERSION} =~ ^(10|11|12|13|14)$ ]]; then + INVALID_OPTIONS+=("${OPTARG}") + fi + ;; + p) + PHP_VERSION=${OPTARG} + if ! [[ ${PHP_VERSION} =~ ^(7.4|8.0|8.1|8.2)$ ]]; then + INVALID_OPTIONS+=("p ${OPTARG}") + fi + ;; + t) + TYPO3_VERSION=${OPTARG} + if ! [[ ${TYPO3_VERSION} =~ ^(11|12)$ ]]; then + INVALID_OPTIONS+=("p ${OPTARG}") + fi + ;; + e) + EXTRA_TEST_OPTIONS=${OPTARG} + ;; + x) + PHP_XDEBUG_ON=1 + ;; + y) + PHP_XDEBUG_PORT=${OPTARG} + ;; + z) + USED_XDEBUG_MODES=${OPTARG} + ;; + h) + echo "${HELP}" + exit 0 + ;; + n) + CGLCHECK_DRY_RUN="-n" + ;; + u) + TEST_SUITE=update + ;; + v) + SCRIPT_VERBOSE=1 + ;; + \?) + INVALID_OPTIONS+=(${OPTARG}) + ;; + :) + INVALID_OPTIONS+=(${OPTARG}) + ;; + esac +done + +# Exit on invalid options +if [ ${#INVALID_OPTIONS[@]} -ne 0 ]; then + echo "Invalid option(s):" >&2 + for I in "${INVALID_OPTIONS[@]}"; do + echo "-"${I} >&2 + done + echo >&2 + echo "${HELP}" >&2 + exit 1 +fi + +# Move "7.2" to "php72", the latter is the docker container name +DOCKER_PHP_IMAGE=`echo "php${PHP_VERSION}" | sed -e 's/\.//'` + +# Set $1 to first mass argument, this is the optional test file or test directory to execute +shift $((OPTIND - 1)) +TEST_FILE=${1} +if [ -n "${1}" ]; then + TEST_FILE=".Build/public/typo3conf/ext/news/${1}" +fi + +if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x +fi + +if [ -z ${TEST_SUITE} ]; then + echo "${HELP}" + exit 0 +fi + +# Suite execution +case ${TEST_SUITE} in + cgl) + # Active dry-run for cgl needs not "-n" but specific options + if [[ ! -z ${CGLCHECK_DRY_RUN} ]]; then + CGLCHECK_DRY_RUN="--dry-run --diff" + fi + setUpDockerComposeDotEnv + docker-compose run cgl + SUITE_EXIT_CODE=$? + docker-compose down + ;; + clean) + rm -rf \ + ../../var/ \ + ../../.cache \ + ../../composer.lock \ + ../../.Build/ \ + ../../Tests/Acceptance/Support/_generated/ \ + ../../composer.json.testing + ;; + composer) + setUpDockerComposeDotEnv + docker-compose run composer + SUITE_EXIT_CODE=$? + docker-compose down + ;; + composerInstall) + setUpDockerComposeDotEnv + cp ../../composer.json ../../composer.json.orig + if [ -f "../../composer.json.testing" ]; then + cp ../../composer.json ../../composer.json.orig + fi + docker-compose run composer_install + cp ../../composer.json ../../composer.json.testing + mv ../../composer.json.orig ../../composer.json + SUITE_EXIT_CODE=$? + docker-compose down + ;; + composerInstallLowest) + setUpDockerComposeDotEnv + cp ../../composer.json ../../composer.json.orig + if [ -f "../../composer.json.testing" ]; then + cp ../../composer.json ../../composer.json.orig + fi + docker-compose run composer_install_lowest + cp ../../composer.json ../../composer.json.testing + mv ../../composer.json.orig ../../composer.json + SUITE_EXIT_CODE=$? + docker-compose down + ;; + composerInstallHighest) + setUpDockerComposeDotEnv + cp ../../composer.json ../../composer.json.orig + if [ -f "../../composer.json.testing" ]; then + cp ../../composer.json ../../composer.json.orig + fi + docker-compose run composer_install_highest + cp ../../composer.json ../../composer.json.testing + mv ../../composer.json.orig ../../composer.json + SUITE_EXIT_CODE=$? + docker-compose down + ;; + coveralls) + setUpDockerComposeDotEnv + docker-compose run coveralls + SUITE_EXIT_CODE=$? + docker-compose down + ;; + functional) + handleDbmsAndDriverOptions + setUpDockerComposeDotEnv + case ${DBMS} in + mariadb) + echo "Using driver: ${DATABASE_DRIVER}" + docker-compose run functional_mariadb + SUITE_EXIT_CODE=$? + ;; + mysql) + echo "Using driver: ${DATABASE_DRIVER}" + docker-compose run functional_mysql + SUITE_EXIT_CODE=$? + ;; + postgres) + docker-compose run functional_postgres + SUITE_EXIT_CODE=$? + ;; + sqlite) + # sqlite has a tmpfs as Web/typo3temp/var/tests/functional-sqlite-dbs/ + # Since docker is executed as root (yay!), the path to this dir is owned by + # root if docker creates it. Thank you, docker. We create the path beforehand + # to avoid permission issues. + mkdir -p ${ROOT_DIR}/public/typo3temp/var/tests/functional-sqlite-dbs/ + docker-compose run functional_sqlite + SUITE_EXIT_CODE=$? + ;; + *) + echo "Invalid -d option argument ${DBMS}" >&2 + echo >&2 + echo "${HELP}" >&2 + exit 1 + esac + docker-compose down + ;; + lint) + setUpDockerComposeDotEnv + docker-compose run lint + SUITE_EXIT_CODE=$? + docker-compose down + ;; + phpstan) + setUpDockerComposeDotEnv + docker-compose run phpstan + SUITE_EXIT_CODE=$? + docker-compose down + ;; + phpstanGenerateBaseline) + setUpDockerComposeDotEnv + docker-compose run phpstan_generate_baseline + SUITE_EXIT_CODE=$? + docker-compose down + ;; + unit) + setUpDockerComposeDotEnv + docker-compose run unit + SUITE_EXIT_CODE=$? + docker-compose down + ;; + update) + # pull typo3/core-testing-*:latest versions of those ones that exist locally + docker images typo3/core-testing-*:latest --format "{{.Repository}}:latest" | xargs -I {} docker pull {} + # remove "dangling" typo3/core-testing-* images (those tagged as ) + docker images typo3/core-testing-* --filter "dangling=true" --format "{{.ID}}" | xargs -I {} docker rmi {} + ;; + *) + echo "Invalid -s option argument ${TEST_SUITE}" >&2 + echo >&2 + echo "${HELP}" >&2 + exit 1 +esac + +exit $SUITE_EXIT_CODE diff --git a/Build/UnitTests.xml b/Build/UnitTests.xml deleted file mode 100644 index 91890ea315..0000000000 --- a/Build/UnitTests.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - ../Tests/Unit/ - - - - - ../Classes/ - - - - diff --git a/Build/php-cs-fixer/php-cs-fixer.php b/Build/php-cs-fixer/php-cs-fixer.php new file mode 100644 index 0000000000..a3eefaae24 --- /dev/null +++ b/Build/php-cs-fixer/php-cs-fixer.php @@ -0,0 +1,76 @@ +setHeader( + 'This file is part of the "news" Extension for TYPO3 CMS. + +For the full copyright and license information, please read the +LICENSE.txt file that was distributed with this source code.', + true +); +$config->setFinder( + (new PhpCsFixer\Finder()) + ->in(realpath(__DIR__ . '/../../')) + ->ignoreVCSIgnored(true) + ->notPath('/^.Build\//') + ->notPath('/^Build\/php-cs-fixer\/php-cs-fixer.php/') + ->notPath('/^Build\/phpunit\/(UnitTestsBootstrap|FunctionalTestsBootstrap).php/') + ->notPath('/^Configuration\//') + ->notPath('/^Documentation\//') + ->notName('/^ext_(emconf|localconf|tables).php/') +) + ->setRiskyAllowed(true) + ->setRules([ + '@DoctrineAnnotation' => true, + '@PER' => true, + 'array_syntax' => ['syntax' => 'short'], + 'blank_line_after_opening_tag' => true, + 'braces' => ['allow_single_line_closure' => true], + 'cast_spaces' => ['space' => 'none'], + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => ['space' => 'none'], + 'dir_constant' => true, + 'function_typehint_space' => true, + 'lowercase_cast' => true, + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], + 'modernize_types_casting' => true, + 'native_function_casing' => true, + 'new_with_braces' => true, + 'no_alias_functions' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_blank_lines' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_singleline' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_nullsafe_operator' => true, + 'no_whitespace_in_blank_line' => true, + 'ordered_imports' => true, + 'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']], + 'php_unit_mock_short_will_return' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_scalar' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'return_type_declaration' => ['space_before' => 'none'], + 'single_quote' => true, + 'single_line_comment_style' => ['comment_types' => ['hash']], + 'single_trait_insert_per_statement' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], + ]); +return $config; diff --git a/Build/phpunit/FunctionalTests.xml b/Build/phpunit/FunctionalTests.xml new file mode 100644 index 0000000000..80156d2501 --- /dev/null +++ b/Build/phpunit/FunctionalTests.xml @@ -0,0 +1,52 @@ + + + + + + ../../Tests/Functional/ + + + + + + + + + + diff --git a/Tests/Build/FunctionalTestsBootstrap.php b/Build/phpunit/FunctionalTestsBootstrap.php similarity index 100% rename from Tests/Build/FunctionalTestsBootstrap.php rename to Build/phpunit/FunctionalTestsBootstrap.php diff --git a/Build/phpunit/UnitTests.xml b/Build/phpunit/UnitTests.xml new file mode 100644 index 0000000000..d09d8ef1c0 --- /dev/null +++ b/Build/phpunit/UnitTests.xml @@ -0,0 +1,45 @@ + + + + + + ../../Tests/Unit/ + + + + + + + diff --git a/Tests/Build/UnitTestsBootstrap.php b/Build/phpunit/UnitTestsBootstrap.php similarity index 98% rename from Tests/Build/UnitTestsBootstrap.php rename to Build/phpunit/UnitTestsBootstrap.php index 0e679f40e9..5b5bbd00ac 100644 --- a/Tests/Build/UnitTestsBootstrap.php +++ b/Build/phpunit/UnitTestsBootstrap.php @@ -13,7 +13,7 @@ */ /** - * Boilerplate for a functional test phpunit boostrap file. + * Boilerplate for a unit test phpunit boostrap file. * * This file is loosely maintained within TYPO3 testing-framework, extensions * are encouraged to not use it directly, but to copy it to an own place, diff --git a/Build/testing-docker/docker-compose.yml b/Build/testing-docker/docker-compose.yml new file mode 100644 index 0000000000..f85e62da46 --- /dev/null +++ b/Build/testing-docker/docker-compose.yml @@ -0,0 +1,427 @@ +version: '2.3' +services: + #--------------------------------------------------------------------------------------------------------------------- + # additional services needed for functional tests to be linked, e.g. databases + #--------------------------------------------------------------------------------------------------------------------- + mysql: + image: mysql:${MYSQL_VERSION} + environment: + MYSQL_ROOT_PASSWORD: funcp + tmpfs: + - /var/lib/mysql/:rw,noexec,nosuid + + mariadb: + image: mariadb:${MARIADB_VERSION} + environment: + MYSQL_ROOT_PASSWORD: funcp + tmpfs: + - /var/lib/mysql/:rw,noexec,nosuid + + postgres: + image: postgres:${POSTGRES_VERSION}-alpine + environment: + POSTGRES_PASSWORD: funcp + POSTGRES_USER: funcu + tmpfs: + - /var/lib/postgresql/data:rw,noexec,nosuid + + #--------------------------------------------------------------------------------------------------------------------- + # composer related services + #--------------------------------------------------------------------------------------------------------------------- + composer: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + composer ${EXTRA_TEST_OPTIONS}; + " + + composer_install: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + if [ ${TYPO3_VERSION} -eq 11 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^11.5.24 + fi + if [ ${TYPO3_VERSION} -eq 12 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^12.2 + fi + composer install --no-progress; + " + + composer_install_lowest: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + if [ ${TYPO3_VERSION} -eq 11 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^11.5.24 + fi + if [ ${TYPO3_VERSION} -eq 12 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^12.0 + fi + composer update --no-ansi --no-interaction --no-progress --with-dependencies --prefer-lowest; + composer show; + " + + composer_install_highest: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + if [ ${TYPO3_VERSION} -eq 11 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^11.5.24 + fi + if [ ${TYPO3_VERSION} -eq 12 ]; then + composer require --no-ansi --no-interaction --no-progress --no-install \ + typo3/cms-core:^12.2 + fi + composer update --no-progress --no-interaction; + composer show; + " + + #--------------------------------------------------------------------------------------------------------------------- + # unit tests + #--------------------------------------------------------------------------------------------------------------------- + unit: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + if [ ${PHP_XDEBUG_ON} -eq 0 ]; then + XDEBUG_MODE=\"off\" \ + .Build/bin/phpunit -c Build/phpunit/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; + else + XDEBUG_MODE=\"${USED_XDEBUG_MODES}\" \ + XDEBUG_TRIGGER=\"foo\" \ + XDEBUG_CONFIG=\"client_host=host.docker.internal\" \ + .Build/bin/phpunit -c Build/phpunit/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; + fi + " + + lint: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + find . -name \\*.php ! -path "./.Build/\\*" -print0 | xargs -0 -n1 -P4 php -dxdebug.mode=off -l >/dev/null + " + + #--------------------------------------------------------------------------------------------------------------------- + # functional tests against different dbms + #--------------------------------------------------------------------------------------------------------------------- + functional_sqlite: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + tmpfs: + - ${ROOT_DIR}/public/typo3temp/var/tests/functional-sqlite-dbs/:rw,noexec,nosuid,uid=${HOST_UID} + environment: + typo3DatabaseDriver: pdo_sqlite + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + if [ ${PHP_XDEBUG_ON} -eq 0 ]; then + XDEBUG_MODE=\"off\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE}; + else + XDEBUG_MODE=\"${USED_XDEBUG_MODES}\" \ + XDEBUG_TRIGGER=\"foo\" \ + XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=host.docker.internal\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE}; + fi + " + + functional_postgres: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + links: + - postgres + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + environment: + typo3DatabaseDriver: pdo_pgsql + typo3DatabaseName: bamboo + typo3DatabaseUsername: funcu + typo3DatabaseHost: postgres + typo3DatabasePassword: funcp + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + echo Waiting for database start...; + while ! nc -z postgres 5432; do + sleep 1; + done; + echo Database is up; + php -v | grep '^PHP'; + if [ ${PHP_XDEBUG_ON} -eq 0 ]; then + XDEBUG_MODE=\"off\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE}; + else + XDEBUG_MODE=\"${USED_XDEBUG_MODES}\" \ + XDEBUG_TRIGGER=\"foo\" \ + XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=host.docker.internal\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE}; + fi + " + + functional_mysql: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + links: + - mysql + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + environment: + typo3DatabaseDriver: "${DATABASE_DRIVER}" + typo3DatabaseName: func_test + typo3DatabaseUsername: root + typo3DatabasePassword: funcp + typo3DatabaseHost: mysql + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + echo Waiting for database start...; + while ! nc -z mysql 3306; do + sleep 1; + done; + echo Database is up; + php -v | grep '^PHP'; + if [ ${PHP_XDEBUG_ON} -eq 0 ]; then + XDEBUG_MODE=\"off\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; + else + XDEBUG_MODE=\"${USED_XDEBUG_MODES}\" \ + XDEBUG_TRIGGER=\"foo\" \ + XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=host.docker.internal\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; + fi + " + + functional_mariadb: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + links: + - mariadb + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + environment: + typo3DatabaseDriver: "${DATABASE_DRIVER}" + typo3DatabaseName: func_test + typo3DatabaseUsername: root + typo3DatabasePassword: funcp + typo3DatabaseHost: mariadb + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + echo Waiting for database start...; + while ! nc -z mariadb 3306; do + sleep 1; + done; + echo Database is up; + php -v | grep '^PHP'; + if [ ${PHP_XDEBUG_ON} -eq 0 ]; then + XDEBUG_MODE=\"off\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; + else + XDEBUG_MODE=\"${USED_XDEBUG_MODES}\" \ + XDEBUG_TRIGGER=\"foo\" \ + XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=host.docker.internal\" \ + .Build/bin/phpunit -c .Build/public/typo3conf/ext/news/Build/phpunit/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE}; + fi + " + + #--------------------------------------------------------------------------------------------------------------------- + # code quality tools + #--------------------------------------------------------------------------------------------------------------------- + cgl: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + if [ ${PHP_XDEBUG_ON} -eq 0 ]; then + php -dxdebug.mode=off \ + .Build/bin/php-cs-fixer fix \ + -v \ + ${CGLCHECK_DRY_RUN} \ + --config=Build/php-cs-fixer/php-cs-fixer.php \ + --using-cache=no . + else + XDEBUG_MODE=\"debug,develop\" \ + XDEBUG_TRIGGER=\"foo\" \ + XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=host.docker.internal\" \ + PHP_CS_FIXER_ALLOW_XDEBUG=1 \ + .Build/bin/php-cs-fixer fix \ + -v \ + ${CGLCHECK_DRY_RUN} \ + --config=Build/php-cs-fixer/php-cs-fixer.php \ + --using-cache=no . + fi + " + + coveralls: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + php -v | grep '^PHP'; + XDEBUG_MODE=\"coverage\" \ + php -dxdebug.mode=off ./.Build/bin/php-coveralls --coverage_clover=./.Build/logs/clover.xml --json_path=./.Build/logs/coveralls-upload.json -v + " + + phpstan: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + mkdir -p .cache + php -dxdebug.mode=off .Build/bin/phpstan analyze -c ./phpstan.neon --no-progress + " + + phpstan_generate_baseline: + image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest + user: "${HOST_UID}" + volumes: + - ${ROOT_DIR}:${ROOT_DIR} + working_dir: ${ROOT_DIR} + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + COMPOSER_HOME: ".cache/composer-home" + COMPOSER_CACHE_DIR: ".cache/composer" + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + mkdir -p .cache + php -dxdebug.mode=off .Build/bin/phpstan analyze -c ./phpstan.neon --generate-baseline=./phpstan-baseline.neon --allow-empty-baseline + " diff --git a/Classes/Backend/FormDataProvider/NewsFlexFormManipulation.php b/Classes/Backend/FormDataProvider/NewsFlexFormManipulation.php deleted file mode 100644 index d76024d89a..0000000000 --- a/Classes/Backend/FormDataProvider/NewsFlexFormManipulation.php +++ /dev/null @@ -1,282 +0,0 @@ - [ - 'orderBy', 'orderDirection', 'categories', 'categoryConjunction', 'includeSubCategories', - 'archiveRestriction', 'timeRestriction', 'timeRestrictionHigh', 'topNewsRestriction', - 'dateField' - ], - 'additional' => [ - 'limit', 'offset', 'hidePagination', 'topNewsFirst', 'listPid', 'list.paginate.itemsPerPage' - ], - 'template' => [ 'cropMaxCharacters' ], - ]; - - /** - * Fields which are removed in list view - * - * @var array - */ - protected $removedFieldsInListView = [ - 'sDEF' => [ - 'dateField', 'singleNews', 'previewHiddenRecords' - ], - 'additional' => [], - 'template' => [], - ]; - - /** - * Fields which are removed in dateMenu view - * - * @var array - */ - protected $removedFieldsInDateMenuView = [ - 'sDEF' => [ - 'orderBy', 'singleNews' - ], - 'additional' => [ - 'limit', 'offset', 'hidePagination', 'topNewsFirst' , 'backPid', 'previewHiddenRecords', 'excludeAlreadyDisplayedNews', - 'list.paginate.itemsPerPage' - ], - 'template' => [ - 'cropMaxCharacters', 'media.maxWidth', 'media.maxHeight' - ], - ]; - - /** - * Fields which are removed in search form view - * - * @var array - */ - protected $removedFieldsInSearchFormView = [ - 'sDEF' => [ - 'orderBy', 'orderDirection', 'categories', 'categoryConjunction', 'includeSubCategories', - 'archiveRestriction', 'timeRestriction', 'timeRestrictionHigh', 'topNewsRestriction', - 'startingpoint', 'recursive', 'dateField', 'singleNews', 'previewHiddenRecords' - ], - 'additional' => [ - 'limit', 'offset', 'hidePagination', 'topNewsFirst', 'detailPid', 'backPid', 'excludeAlreadyDisplayedNews', - 'list.paginate.itemsPerPage' - ], - 'template' => [ - 'cropMaxCharacters', 'media.maxWidth', 'media.maxHeight' - ], - ]; - - /** - * Fields which are removed in category list view - * - * @var array - */ - protected $removedFieldsInCategoryListView = [ - 'sDEF' => [ - 'orderBy', 'orderDirection', 'categoryConjunction', 'includeSubCategories', - 'archiveRestriction', 'timeRestriction', 'timeRestrictionHigh', 'topNewsRestriction', - 'recursive', 'dateField', 'singleNews', 'previewHiddenRecords', - ], - 'additional' => [ - 'limit', 'offset', 'hidePagination', 'topNewsFirst', 'detailPid', 'backPid', 'excludeAlreadyDisplayedNews', - 'list.paginate.itemsPerPage' - ], - 'template' => [ - 'cropMaxCharacters', 'media.maxWidth', 'media.maxHeight' - ], - ]; - - /** - * Fields which are removed in tag list view - * - * @var array - */ - protected $removedFieldsInTagListView = [ - 'sDEF' => [ - 'categories', 'categoryConjunction', 'includeSubCategories', - 'archiveRestriction', 'timeRestriction', 'timeRestrictionHigh', 'topNewsRestriction', - 'dateField', 'singleNews', 'previewHiddenRecords' - ], - 'additional' => [ - 'hidePagination', 'topNewsFirst', 'detailPid', 'backPid', 'excludeAlreadyDisplayedNews', - 'list.paginate.itemsPerPage' - ], - 'template' => [ - 'cropMaxCharacters', 'media.maxWidth', 'media.maxHeight' - ] - ]; - - /** - * @var EmConfiguration - */ - protected $configuration; - - public function __construct() - { - $this->configuration = GeneralUtility::makeInstance(EmConfiguration::class); - } - - /** - * Remove fields depending on switchable controller action in tt_content - * Restrict category selection based on configuration in tt_content - * - * @param array $result - * @return array - */ - public function addData(array $result): array - { - if ($result['tableName'] === 'tt_content' - && $result['databaseRow']['CType'] === 'list' - && $result['databaseRow']['list_type'] === 'news_pi1' - && is_array($result['processedTca']['columns']['pi_flexform']['config']['ds']) - ) { - $result = $this->updateFlexForms($result); - if ($this->enabledInTsConfig($result)) { - $result = $this->addCategoryConstraints($result); - } - } - - return $result; - } - - /** - * Update flexform configuration if a action is selected - * - * @param array $result Full data - * @return array Modified data - */ - protected function updateFlexForms(array $result): array - { - $selectedView = ''; - $row = $result['databaseRow']; - $dataStructure = $result['processedTca']['columns']['pi_flexform']['config']['ds']; - - // get the first selected action - $flexformSelection = $row['pi_flexform']; - if (is_array($flexformSelection) - && is_array($flexformSelection['data']) - && !empty($flexformSelection['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF']) - ) { - $selectedView = $flexformSelection['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF']; - $actionParts = GeneralUtility::trimExplode(';', $selectedView, true); - $selectedView = $actionParts[0]; - } elseif ($result['command'] === 'new') { - // new plugin element, use List as starting view - $selectedView = 'News->list'; - } - - if (!empty($selectedView)) { - // Modify the flexform structure depending on the first found action - switch ($selectedView) { - case 'News->list': - case 'News->searchResult': - $dataStructure = $this->deleteFromStructure($dataStructure, $this->removedFieldsInListView); - break; - case 'News->detail': - $dataStructure = $this->deleteFromStructure($dataStructure, $this->removedFieldsInDetailView); - break; - case 'News->searchForm': - $dataStructure = $this->deleteFromStructure($dataStructure, $this->removedFieldsInSearchFormView); - break; - case 'News->dateMenu': - $dataStructure = $this->deleteFromStructure($dataStructure, $this->removedFieldsInDateMenuView); - break; - case 'Category->list': - $dataStructure = $this->deleteFromStructure($dataStructure, $this->removedFieldsInCategoryListView); - break; - case 'Tag->list': - $dataStructure = $this->deleteFromStructure($dataStructure, $this->removedFieldsInTagListView); - break; - default: - } - - $params = [ - 'selectedView' => $selectedView, - 'dataStructure' => &$dataStructure, - ]; - foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Hooks/BackendUtility.php']['updateFlexforms'] ?? [] as $reference) { - GeneralUtility::callUserFunction($reference, $params, $this); - } - } - - $result['processedTca']['columns']['pi_flexform']['config']['ds'] = $dataStructure; - - return $result; - } - - /** - * Add category restriction to flexforms - * - * @param array $result - * @return array Modified result - */ - protected function addCategoryConstraints($result): array - { - $structure = $result['processedTca']['columns']['pi_flexform']['config']['ds']; - $categoryRestrictionSetting = $this->configuration->getCategoryRestriction(); - $categoryRestriction = ''; - switch ($categoryRestrictionSetting) { - case 'current_pid': - $categoryRestriction = ' AND sys_category.pid=###CURRENT_PID### '; - break; - case 'siteroot': - $categoryRestriction = ' AND sys_category.pid IN (###SITEROOT###) '; - break; - case 'page_tsconfig': - $categoryRestriction = ' AND sys_category.pid IN (###PAGE_TSCONFIG_IDLIST###) '; - break; - } - - if (!empty($categoryRestriction) && isset($structure['sheets']['sDEF']['ROOT']['el']['settings.categories'])) { - $structure['sheets']['sDEF']['ROOT']['el']['settings.categories']['config']['foreign_table_where'] = $categoryRestriction . $structure['sheets']['sDEF']['ROOT']['el']['settings.categories']['config']['foreign_table_where']; - } - $result['processedTca']['columns']['pi_flexform']['config']['ds'] = $structure; - return $result; - } - - /** - * Remove fields from flexform structure - * - * @param array &$dataStructure flexform structure - * @param array $fieldsToBeRemoved fields which need to be removed - * @return array Modified structure - */ - protected function deleteFromStructure(array $dataStructure, array $fieldsToBeRemoved): array - { - foreach ($fieldsToBeRemoved as $sheetName => $fieldsInSheet) { - foreach ($fieldsInSheet as $fieldName) { - unset($dataStructure['sheets'][$sheetName]['ROOT']['el']['settings.' . $fieldName]); - } - } - return $dataStructure; - } - - /** - * @param array $result Incoming array - * @return bool - */ - protected function enabledInTsConfig(array $result): bool - { - return (bool)($result['pageTsConfig']['tx_news.']['categoryRestrictionForFlexForms'] ?? false); - } -} diff --git a/Classes/Backend/FormDataProvider/NewsRowInitializeNew.php b/Classes/Backend/FormDataProvider/NewsRowInitializeNew.php index 6d8d7026ff..18f719e8a3 100644 --- a/Classes/Backend/FormDataProvider/NewsRowInitializeNew.php +++ b/Classes/Backend/FormDataProvider/NewsRowInitializeNew.php @@ -1,14 +1,14 @@ [ 'action' => 'detail', 'controller' => 'News', - 'news' => $recordId - ] + 'news' => $recordId, + ], ]; return (string)$site->getRouter()->generateUri( (string)$pageId, diff --git a/Classes/Backend/RecordList/NewsDatabaseRecordList.php b/Classes/Backend/RecordList/NewsDatabaseRecordList.php index 9ef8d6399d..99cb676bb3 100644 --- a/Classes/Backend/RecordList/NewsDatabaseRecordList.php +++ b/Classes/Backend/RecordList/NewsDatabaseRecordList.php @@ -1,13 +1,14 @@ id; } if (isset($this->thumbs)) { diff --git a/Classes/Backend/RecordList/RecordListConstraint.php b/Classes/Backend/RecordList/RecordListConstraint.php index d37ab62ff0..9ce0ecee96 100644 --- a/Classes/Backend/RecordList/RecordListConstraint.php +++ b/Classes/Backend/RecordList/RecordListConstraint.php @@ -1,13 +1,14 @@ orX(...$likeParts); + $fieldParts[] = $expressionBuilder->or(...$likeParts); } } - $parameters['whereDoctrine'][] = $expressionBuilder->orX(...$fieldParts); - $parameters['where'][] = $expressionBuilder->orX(...$fieldParts); + $parameters['whereDoctrine'][] = $expressionBuilder->or(...$fieldParts); + $parameters['where'][] = $expressionBuilder->or(...$fieldParts); } // top news $topNewsSetting = (int)$arguments['topNewsRestriction']; @@ -83,13 +84,13 @@ public function extendQuery(array &$parameters, array $arguments): void $currentTime = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'); if ($archived === 1) { $parameters['where'][] = '(archive > ' . $currentTime . ' OR archive=0)'; - $parameters['whereDoctrine'][] = $expressionBuilder->orX( + $parameters['whereDoctrine'][] = $expressionBuilder->or( $expressionBuilder->gt('archive', $currentTime), $expressionBuilder->eq('archive', 0) ); } elseif ($archived === 2) { $parameters['where'][] = 'archive > 0 AND archive <' . $currentTime; - $parameters['whereDoctrine'][] = $expressionBuilder->andX( + $parameters['whereDoctrine'][] = $expressionBuilder->and( $expressionBuilder->gt('archive', 0), $expressionBuilder->lt('archive', $currentTime) ); @@ -171,10 +172,10 @@ public function extendQuery(array &$parameters, array $arguments): void $parameters['whereDoctrine'][] = $expressionBuilder->eq('uid', 0); } else { $parameters['where'][] = implode(' OR ', $orConstraint); - $parameters['whereDoctrine'][] = $expressionBuilder->orX(...$orConstraintDoctrine); + $parameters['whereDoctrine'][] = $expressionBuilder->or(...$orConstraintDoctrine); } break; - // @todo test that + // @todo test that case 'notor': $orConstraint = $orConstraintDoctrine = []; foreach ($arguments['selectedCategories'] as $category) { @@ -193,7 +194,7 @@ public function extendQuery(array &$parameters, array $arguments): void } else { $orConstraint = array_unique($orConstraint); $parameters['where'][] = ' NOT (' . implode(' OR ', $orConstraint) . ')'; - $parameters['whereDoctrine'][] = $expressionBuilder->andX(...$orConstraintDoctrine); + $parameters['whereDoctrine'][] = $expressionBuilder->and(...$orConstraintDoctrine); } break; case 'notand': @@ -248,10 +249,10 @@ protected function getNewsIdsOfCategory($categoryId): array $queryBuilder->expr()->isNotNull('tx_news_domain_model_news.uid'), $queryBuilder->expr()->eq('sys_category.uid', $queryBuilder->createNamedParameter($categoryId, \PDO::PARAM_INT)) ) - ->execute(); + ->executeQuery(); $idList = []; - while ($row = $res->fetch()) { + while ($row = $res->fetchAssociative()) { $idList[] = $row['uid']; } diff --git a/Classes/Command/ProxyClassRebuildCommand.php b/Classes/Command/ProxyClassRebuildCommand.php index 6d0aa0b795..690008308f 100644 --- a/Classes/Command/ProxyClassRebuildCommand.php +++ b/Classes/Command/ProxyClassRebuildCommand.php @@ -2,7 +2,7 @@ declare(strict_types=1); -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the diff --git a/Classes/Controller/AdministrationController.php b/Classes/Controller/AdministrationController.php index 68555f32f5..1769615c9a 100644 --- a/Classes/Controller/AdministrationController.php +++ b/Classes/Controller/AdministrationController.php @@ -1,17 +1,18 @@ administrationRepository = $administrationRepository; } - public function indexAction(): void + public function indexAction(): ResponseInterface { $this->view->assignMultiple([ - 'counts' => $this->administrationRepository->getTotalCounts() + 'counts' => $this->administrationRepository->getTotalCounts(), ]); + return $this->htmlResponse(); } } diff --git a/Classes/Controller/CategoryController.php b/Classes/Controller/CategoryController.php index 4dc7f1abb3..b484b053f2 100644 --- a/Classes/Controller/CategoryController.php +++ b/Classes/Controller/CategoryController.php @@ -1,15 +1,17 @@ createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); @@ -47,5 +45,6 @@ public function listAction(array $overwriteDemand = null) $event = $this->eventDispatcher->dispatch(new CategoryListActionEvent($this, $assignedValues, $this->request)); $this->view->assignMultiple($event->getAssignedValues()); + return $this->htmlResponse(); } } diff --git a/Classes/Controller/ImportController.php b/Classes/Controller/ImportController.php deleted file mode 100644 index 5fbc374bdc..0000000000 --- a/Classes/Controller/ImportController.php +++ /dev/null @@ -1,160 +0,0 @@ -objectManager->get($registeredJob['className']); - if ($jobInstance instanceof ImportJobInterface && $jobInstance->isEnabled()) { - $availableJobs[$registeredJob['className']] = $GLOBALS['LANG']->sL($registeredJob['title']); - } - } - - return $availableJobs; - } - - /** - * Shows the import jobs selection . - * - * @return void - */ - public function indexAction(): void - { - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); - $pageRenderer->loadRequireJsModule('TYPO3/CMS/News/Import'); - - $this->view->assignMultiple( - [ - 'error' => $this->checkCorrectConfiguration(), - 'availableJobs' => array_merge([0 => ''], $this->getAvailableJobs()), - 'moduleUrl' => $uriBuilder->buildUriFromRoute($this->request->getPluginName()) - ] - ); - } - - /** - * Check for correct configuration - * - * @return string - * @throws Exception - * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException - */ - protected function checkCorrectConfiguration(): string - { - $error = ''; - - $settings = GeneralUtility::makeInstance(EmConfiguration::class); - - try { - $storageId = (int)$settings->getStorageUidImporter(); - $path = $settings->getResourceFolderImporter(); - if ($storageId === 0) { - throw new UnexpectedValueException('import.error.configuration.storageUidImporter'); - } - if (empty($path)) { - throw new UnexpectedValueException('import.error.configuration.resourceFolderImporter'); - } - $storage = $this->getResourceFactory()->getStorageObject($storageId); - $pathExists = $storage->hasFolder($path); - if (!$pathExists) { - throw new FolderDoesNotExistException('Folder does not exist', 1474827988); - } - } catch (FolderDoesNotExistException $e) { - $error = 'import.error.configuration.resourceFolderImporter.notExist'; - } catch (UnexpectedValueException $e) { - $error = $e->getMessage(); - } - return $error; - } - - /** - * Runs an actual job. - * - * @param string $jobClassName - * @param int $offset - * @return string - */ - public function runJobAction($jobClassName, $offset = 0): string - { - /** @var ImportJobInterface $job */ - $job = $this->objectManager->get($jobClassName); - $job->run($offset); - - return 'OK'; - } - - /** - * Retrieves the job info of a given jobClass - * - * @param string $jobClassName - * @return string - */ - public function jobInfoAction($jobClassName): string - { - $response = null; - try { - /** @var ImportJobInterface $job */ - $job = $this->objectManager->get($jobClassName); - $response = $job->getInfo(); - } catch (Exception $e) { - $response['message'] = $e->getMessage(); - $response['line'] = $e->getLine(); - $response['trace'] = $e->getTrace(); - - HttpUtility::setResponseCode(HttpUtility::HTTP_STATUS_400); - } - - return json_encode($response); - } - - /** - * @return ResourceFactory - */ - protected function getResourceFactory(): ResourceFactory - { - return GeneralUtility::makeInstance(ResourceFactory::class); - } -} diff --git a/Classes/Controller/NewsBaseController.php b/Classes/Controller/NewsBaseController.php index 7ec3d84e4c..7e15da5178 100644 --- a/Classes/Controller/NewsBaseController.php +++ b/Classes/Controller/NewsBaseController.php @@ -1,85 +1,33 @@ assign('contentObjectData', $this->configurationManager->getContentObject()->data); $view->assign('emConfiguration', GeneralUtility::makeInstance(EmConfiguration::class)); if (isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE'])) { $view->assign('pageData', $GLOBALS['TSFE']->page); } - parent::initializeView($view); - } - -// /** -// * @param RequestInterface $request -// * @param ResponseInterface $response -// * @throws \Exception -// */ -// public function processRequest(RequestInterface $request, ResponseInterface $response) -// { -// try { -// parent::processRequest($request, $response); -// } catch (\Exception $exception) { -// $this->handleKnownExceptionsElseThrowAgain($exception); -// } -// } - - /** - * @param \Exception $exception - * - * @throws \Exception - * - * @return void - */ - private function handleKnownExceptionsElseThrowAgain(\Exception $exception): void - { - $previousException = $exception->getPrevious(); - - if ( - $this->actionMethodName === 'detailAction' - && $previousException instanceof \TYPO3\CMS\Extbase\Property\Exception - && isset($this->settings['detail']['errorHandling']) - ) { - $this->handleNoNewsFoundError($this->settings['detail']['errorHandling']); - } else { - throw $exception; - } } /** @@ -88,10 +36,10 @@ private function handleKnownExceptionsElseThrowAgain(\Exception $exception): voi * @param string $configuration configuration what will be done * @throws \InvalidArgumentException */ - protected function handleNoNewsFoundError($configuration): string + protected function handleNoNewsFoundError(string $configuration): ?ResponseInterface { if (empty($configuration)) { - return ''; + return null; } $options = GeneralUtility::trimExplode(',', $configuration, true); @@ -123,41 +71,27 @@ protected function handleNoNewsFoundError($configuration): string break; case 'pageNotFoundHandler': - $typo3Information = GeneralUtility::makeInstance(Typo3Version::class); - if ($typo3Information->getMajorVersion() === 9) { - $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction($GLOBALS['TYPO3_REQUEST'], 'No news entry found.'); - throw new ImmediateResponseException($response); - } - $message = 'No news entry found!'; - $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( - $GLOBALS['TYPO3_REQUEST'], - $message - ); - throw new ImmediateResponseException($response, 1590468229); - - break; + $message = 'No news entry found!'; + $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( + $GLOBALS['TYPO3_REQUEST'], + $message + ); + throw new ImmediateResponseException($response, 1590468229); case 'showStandaloneTemplate': - if (isset($options[2])) { - $statusCode = constant(HttpUtility::class . '::HTTP_STATUS_' . $options[2]); - } else { - $statusCode = HttpUtility::HTTP_STATUS_404; - } - HttpUtility::setResponseCode($statusCode); + $statusCode = (int)($options[2] ?? 404); $this->getTypoScriptFrontendController()->set_no_cache('News record not found'); $standaloneTemplate = GeneralUtility::makeInstance(StandaloneView::class); $standaloneTemplate->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($options[1])); - return $standaloneTemplate->render(); - break; - default: - return ''; + + return $this->responseFactory->createResponse($statusCode) + ->withHeader('Content-Type', 'text/html; charset=utf-8') + ->withBody($this->streamFactory->createStream($standaloneTemplate->render())); } + return null; } - /** - * @return TypoScriptFrontendController - */ protected function getTypoScriptFrontendController(): TypoScriptFrontendController { return $GLOBALS['TSFE']; diff --git a/Classes/Controller/NewsController.php b/Classes/Controller/NewsController.php index f7cfc5bdab..a84178b39e 100644 --- a/Classes/Controller/NewsController.php +++ b/Classes/Controller/NewsController.php @@ -1,5 +1,12 @@ reBuildSimple(); $this->buildSettings(); if (isset($this->settings['format'])) { - $this->request->setFormat($this->settings['format']); + $this->request = $this->request->withFormat($this->settings['format']); } // Only do this in Frontend Context if (!empty($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE'])) { @@ -212,12 +211,13 @@ protected function overwriteDemandObject(NewsDemand $demand, array $overwriteDem * Output a list view of news * * @param array|null $overwriteDemand - * - * @return void */ - public function listAction(array $overwriteDemand = null) + public function listAction(array $overwriteDemand = null): ResponseInterface { - $this->forwardToDetailActionWhenRequested(); + $possibleRedirect = $this->forwardToDetailActionWhenRequested(); + if ($possibleRedirect) { + return $possibleRedirect; + } $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); @@ -276,20 +276,22 @@ public function listAction(array $overwriteDemand = null) ]); Cache::addPageCacheTagsByDemandObject($demand); + return $this->htmlResponse(); } /** * When list action is called along with a news argument, we forward to detail action. */ - protected function forwardToDetailActionWhenRequested() + protected function forwardToDetailActionWhenRequested(): ?ForwardResponse { if (!$this->isActionAllowed('detail') || !$this->request->hasArgument('news') ) { - return; + return null; } - $this->forward('detail', null, null, ['news' => $this->request->getArgument('news')]); + $forwardResponse = new ForwardResponse('detail'); + return $forwardResponse->withArguments(['news' => $this->request->getArgument('news')]); } /** @@ -301,6 +303,7 @@ protected function forwardToDetailActionWhenRequested() protected function isActionAllowed(string $action): bool { $frameworkConfiguration = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK); + // @extensionScannerIgnoreLine $allowedActions = $frameworkConfiguration['controllerConfiguration']['News']['actions'] ?? []; return \in_array($action, $allowedActions, true); @@ -309,7 +312,7 @@ protected function isActionAllowed(string $action): bool /** * Output a selected list view of news */ - public function selectedListAction(): void + public function selectedListAction(): ResponseInterface { $newsRecords = []; @@ -332,7 +335,7 @@ public function selectedListAction(): void $assignedValues = [ 'news' => $newsRecords, 'demand' => $demand, - 'settings' => $this->settings + 'settings' => $this->settings, ]; $event = $this->eventDispatcher->dispatch(new NewsListSelectedActionEvent($this, $assignedValues, $this->request)); @@ -341,17 +344,16 @@ public function selectedListAction(): void if (!empty($newsRecords) && is_a($newsRecords[0], News::class)) { Cache::addCacheTagsByNewsRecords($newsRecords); } + return $this->htmlResponse(); } /** * Single view of a news record * - * @param \GeorgRinger\News\Domain\Model\News $news news item + * @param News $news news item * @param int $currentPage current page for optional pagination - * - * @return null|string */ - public function detailAction(News $news = null, $currentPage = 1) + public function detailAction(News $news = null, $currentPage = 1): ResponseInterface { if ($news === null || ($this->settings['isShortcut'] ?? false)) { $previewNewsId = (int)($this->settings['singleNews'] ?? 0); @@ -380,7 +382,7 @@ public function detailAction(News $news = null, $currentPage = 1) 'newsItem' => $news, 'currentPage' => (int)$currentPage, 'demand' => $demand, - 'settings' => $this->settings + 'settings' => $this->settings, ]; $event = $this->eventDispatcher->dispatch(new NewsDetailActionEvent($this, $assignedValues, $this->request)); @@ -408,11 +410,12 @@ public function detailAction(News $news = null, $currentPage = 1) $provider->setTitleByNews($news, $providerConfiguration); } } elseif (isset($this->settings['detail']['errorHandling'])) { - $errorContent = $this->handleNoNewsFoundError($this->settings['detail']['errorHandling']); - if ($errorContent) { - return $errorContent; + $errorResponse = $this->handleNoNewsFoundError($this->settings['detail']['errorHandling'] ?? ''); + if ($errorResponse) { + return $errorResponse; } } + return $this->htmlResponse(); } /** @@ -456,12 +459,8 @@ protected function isPreviewOfHiddenRecordsEnabled(): bool /** * Render a menu by dates, e.g. years, months or dates - * - * @param array|null $overwriteDemand - * - * @return void */ - public function dateMenuAction(array $overwriteDemand = null): void + public function dateMenuAction(array $overwriteDemand = null): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); @@ -497,26 +496,22 @@ public function dateMenuAction(array $overwriteDemand = null): void 'news' => $newsRecords, 'overwriteDemand' => $overwriteDemand, 'demand' => $demand, - 'settings' => $this->settings + 'settings' => $this->settings, ]; $event = $this->eventDispatcher->dispatch(new NewsDateMenuActionEvent($this, $assignedValues, $this->request)); $this->view->assignMultiple($event->getAssignedValues()); + return $this->htmlResponse(); } /** * Display the search form - * - * @param \GeorgRinger\News\Domain\Model\Dto\Search $search - * @param array $overwriteDemand - * - * @return void */ public function searchFormAction( Search $search = null, array $overwriteDemand = [] - ): void { + ): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); @@ -533,26 +528,22 @@ public function searchFormAction( 'search' => $search, 'overwriteDemand' => $overwriteDemand, 'demand' => $demand, - 'settings' => $this->settings + 'settings' => $this->settings, ]; $event = $this->eventDispatcher->dispatch(new NewsSearchFormActionEvent($this, $assignedValues, $this->request)); $this->view->assignMultiple($event->getAssignedValues()); + return $this->htmlResponse(); } /** * Displays the search result - * - * @param \GeorgRinger\News\Domain\Model\Dto\Search $search - * @param array $overwriteDemand - * - * @return void */ public function searchResultAction( Search $search = null, array $overwriteDemand = [] - ): void { + ): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); @@ -588,18 +579,17 @@ public function searchResultAction( 'currentPage' => $currentPage, 'paginator' => $paginator, 'pagination' => $pagination, - ] + ], ]; $event = $this->eventDispatcher->dispatch(new NewsSearchResultActionEvent($this, $assignedValues, $this->request)); $this->view->assignMultiple($event->getAssignedValues()); + return $this->htmlResponse(); } /** * initialize search result action - * - * @return void */ public function initializeSearchResultAction(): void { @@ -608,8 +598,6 @@ public function initializeSearchResultAction(): void /** * Initialize search form action - * - * @return void */ public function initializeSearchFormAction(): void { @@ -618,8 +606,6 @@ public function initializeSearchFormAction(): void /** * Initialize searchForm and searchResult actions - * - * @return void */ protected function initializeSearchActions(): void { @@ -689,8 +675,6 @@ public function buildSettings(): void * This function is for testing purposes only. * * @param \TYPO3\CMS\Fluid\View\TemplateView $view the view to inject - * - * @return void */ public function setView(TemplateView $view): void { diff --git a/Classes/Controller/TagController.php b/Classes/Controller/TagController.php index 3cc2e5ce8f..61995647b3 100644 --- a/Classes/Controller/TagController.php +++ b/Classes/Controller/TagController.php @@ -1,29 +1,23 @@ settings['orderBy'] === 'datetime') { @@ -46,5 +40,6 @@ public function listAction(array $overwriteDemand = null) $event = $this->eventDispatcher->dispatch(new TagListActionEvent($this, $assignedValues, $this->request)); $this->view->assignMultiple($event->getAssignedValues()); + return $this->htmlResponse(); } } diff --git a/Classes/DataProcessing/AddNewsToMenuProcessor.php b/Classes/DataProcessing/AddNewsToMenuProcessor.php index d9dea6e928..2d7dabdd40 100644 --- a/Classes/DataProcessing/AddNewsToMenuProcessor.php +++ b/Classes/DataProcessing/AddNewsToMenuProcessor.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * This file is part of the "news" Extension for TYPO3 CMS. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + namespace GeorgRinger\News\DataProcessing; use TYPO3\CMS\Core\Context\Context; @@ -12,13 +19,6 @@ use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; -/** - * This file is part of the "news" Extension for TYPO3 CMS. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - */ - /** * Add the current news record to any menu, e.g. breadcrumb * @@ -56,8 +56,6 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu * * @param array $newsRecord * @param array $menu - * - * @return void */ protected function addNewsRecordToMenu(array $newsRecord, array &$menu): void { @@ -71,7 +69,7 @@ protected function addNewsRecordToMenu(array $newsRecord, array &$menu): void 'active' => 1, 'current' => 1, 'link' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), - 'isNews' => true + 'isNews' => true, ]; } @@ -97,10 +95,10 @@ protected function getNewsRecord(): array ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) ) - ->execute() - ->fetch(); + ->executeQuery()->fetchAssociative(); if ($row) { + // @extensionScannerIgnoreLine $row = $this->getTsfe()->sys_page->getRecordOverlay('tx_news_domain_model_news', $row, $this->getCurrentLanguage()); } diff --git a/Classes/DataProcessing/DisableLanguageMenuProcessor.php b/Classes/DataProcessing/DisableLanguageMenuProcessor.php index 91fdfaa416..1f3176fa60 100644 --- a/Classes/DataProcessing/DisableLanguageMenuProcessor.php +++ b/Classes/DataProcessing/DisableLanguageMenuProcessor.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * This file is part of the "news" Extension for TYPO3 CMS. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + namespace GeorgRinger\News\DataProcessing; use GeorgRinger\News\Seo\NewsAvailability; @@ -11,13 +18,6 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; -/** - * This file is part of the "news" Extension for TYPO3 CMS. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - */ - /** * Disable language item on a detail page if the news is not translated * diff --git a/Classes/Database/QueryGenerator.php b/Classes/Database/QueryGenerator.php new file mode 100644 index 0000000000..75781dff9a --- /dev/null +++ b/Classes/Database/QueryGenerator.php @@ -0,0 +1,72 @@ + 0) { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + $queryBuilder->select('uid') + ->from('pages') + ->where( + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', 0) + ) + ->orderBy('uid'); + + $statement = $queryBuilder->executeQuery(); + while ($row = $statement->fetchAssociative()) { + if ($begin <= 0) { + $theList .= ',' . $row['uid']; + } + if ($depth > 1) { + $theSubList = $this->getTreeList($row['uid'], $depth - 1, $begin - 1); + if (!empty($theList) && !empty($theSubList) && ($theSubList[0] !== ',')) { + $theList .= ','; + } + $theList .= $theSubList; + } + } + } + return (string)$theList; + } +} diff --git a/Classes/Domain/Model/Category.php b/Classes/Domain/Model/Category.php index 8dd549be97..96b07fa384 100644 --- a/Classes/Domain/Model/Category.php +++ b/Classes/Domain/Model/Category.php @@ -1,18 +1,18 @@ contentElementRelation; } - public function getContentElementPreview(): bool - { - return (bool)$this->contentElementPreview; - } - public function getManualSorting(): bool { return (bool)$this->manualSorting; @@ -133,11 +119,6 @@ public function getArchiveDate(): string return $this->archiveDate; } - public function getShowImporter(): bool - { - return (bool)$this->showImporter; - } - public function setShowAdministrationModule($showAdministrationModule): void { $this->showAdministrationModule = $showAdministrationModule; @@ -178,11 +159,6 @@ public function getHidePageTreeForAdministrationModule(): bool return (bool)$this->hidePageTreeForAdministrationModule; } - public function isMediaPreview(): bool - { - return (bool)$this->mediaPreview; - } - public function isAdvancedMediaPreview(): bool { return (bool)$this->advancedMediaPreview; diff --git a/Classes/Domain/Model/Dto/NewsDemand.php b/Classes/Domain/Model/Dto/NewsDemand.php index 777ec8707b..a7262abe60 100644 --- a/Classes/Domain/Model/Dto/NewsDemand.php +++ b/Classes/Domain/Model/Dto/NewsDemand.php @@ -1,13 +1,14 @@ * @TYPO3\CMS\Extbase\Annotation\ORM\Lazy */ - protected $contentElements = null; + protected $contentElements; /** * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\Tag> @@ -269,8 +270,6 @@ public function getTitle(): string * Set title * * @param string $title title - * - * @return void */ public function setTitle($title): void { @@ -291,8 +290,6 @@ public function getAlternativeTitle(): string * Set alternative title * * @param string $alternativeTitle - * - * @return void */ public function setAlternativeTitle($alternativeTitle): void { @@ -313,8 +310,6 @@ public function getTeaser(): string * Set Teaser text * * @param string $teaser teaser text - * - * @return void */ public function setTeaser($teaser): void { @@ -335,8 +330,6 @@ public function getBodytext(): string * Set bodytext * * @param string $bodytext main content - * - * @return void */ public function setBodytext($bodytext): void { @@ -346,7 +339,7 @@ public function setBodytext($bodytext): void /** * Get datetime * - * @return null|DateTime + * @return DateTime|null */ public function getDatetime(): ?DateTime { @@ -357,8 +350,6 @@ public function getDatetime(): ?DateTime * Set date time * * @param DateTime $datetime datetime - * - * @return void */ public function setDatetime($datetime): void { @@ -398,7 +389,7 @@ public function getDayOfDatetime(): int /** * Get archive date * - * @return null|DateTime + * @return DateTime|null */ public function getArchive(): ?DateTime { @@ -409,8 +400,6 @@ public function getArchive(): ?DateTime * Set archive date * * @param DateTime $archive archive date - * - * @return void */ public function setArchive($archive): void { @@ -470,8 +459,6 @@ public function getAuthor(): string * Set author * * @param string $author author - * - * @return void */ public function setAuthor($author): void { @@ -492,8 +479,6 @@ public function getAuthorEmail(): string * Set author's email * * @param string $authorEmail author's email - * - * @return void */ public function setAuthorEmail($authorEmail): void { @@ -503,7 +488,7 @@ public function setAuthorEmail($authorEmail): void /** * Get categories * - * @return null|ObjectStorage + * @return ObjectStorage|null */ public function getCategories(): ?ObjectStorage { @@ -513,7 +498,7 @@ public function getCategories(): ?ObjectStorage /** * Get first category * - * @return null|Category + * @return Category|null */ public function getFirstCategory(): ?Category { @@ -529,8 +514,6 @@ public function getFirstCategory(): ?Category * Set categories * * @param ObjectStorage $categories - * - * @return void */ public function setCategories($categories): void { @@ -541,8 +524,6 @@ public function setCategories($categories): void * Adds a category to this categories. * * @param Category $category - * - * @return void */ public function addCategory(Category $category): void { @@ -563,7 +544,6 @@ public function getRelated() * Set related from * * @param ObjectStorage $relatedFrom - * @return void */ public function setRelatedFrom($relatedFrom): void { @@ -645,8 +625,6 @@ public function getRelatedSorted(): array * Set related news * * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $related related news - * - * @return void */ public function setRelated($related): void { @@ -656,7 +634,7 @@ public function setRelated($related): void /** * Get related links * - * @return null|ObjectStorage + * @return ObjectStorage|null */ public function getRelatedLinks(): ?ObjectStorage { @@ -666,7 +644,7 @@ public function getRelatedLinks(): ?ObjectStorage /** * Get FAL related files * - * @return null|ObjectStorage + * @return ObjectStorage|null */ public function getFalRelatedFiles(): ?ObjectStorage { @@ -676,7 +654,7 @@ public function getFalRelatedFiles(): ?ObjectStorage /** * Short method for getFalRelatedFiles * - * @return null|ObjectStorage + * @return ObjectStorage|null */ public function getRelatedFiles(): ?ObjectStorage { @@ -687,8 +665,6 @@ public function getRelatedFiles(): ?ObjectStorage * Set FAL related files * * @param ObjectStorage $falRelatedFiles FAL related files - * - * @return void */ public function setFalRelatedFiles($falRelatedFiles): void { @@ -699,8 +675,6 @@ public function setFalRelatedFiles($falRelatedFiles): void * Adds a file to this files. * * @param FileReference $file - * - * @return void */ public function addFalRelatedFile(FileReference $file): void { @@ -714,7 +688,6 @@ public function addFalRelatedFile(FileReference $file): void * Set related links * * @param ObjectStorage $relatedLinks related links relation - * @return void */ public function setRelatedLinks($relatedLinks): void { @@ -735,7 +708,6 @@ public function getType(): string * Set type of news * * @param string $type type - * @return void */ public function setType(string $type): void { @@ -756,8 +728,6 @@ public function getKeywords(): string * Set keywords * * @param string $keywords keywords - * - * @return void */ public function setKeywords($keywords): void { @@ -778,8 +748,6 @@ public function getDescription(): string * Set description * * @param string $description description - * - * @return void */ public function setDescription($description): void { @@ -790,8 +758,6 @@ public function setDescription($description): void * Adds a related link. * * @param Link $relatedLink - * - * @return void */ public function addRelatedLink(Link $relatedLink): void { @@ -804,7 +770,7 @@ public function addRelatedLink(Link $relatedLink): void /** * Get the Fal media items * - * @return null|ObjectStorage + * @return ObjectStorage|null */ public function getFalMedia(): ?ObjectStorage { @@ -814,7 +780,7 @@ public function getFalMedia(): ?ObjectStorage /** * Short method for getFalMedia() * - * @return null|ObjectStorage + * @return ObjectStorage|null */ public function getMedia(): ?ObjectStorage { @@ -825,8 +791,6 @@ public function getMedia(): ?ObjectStorage * Set Fal media relation * * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $falMedia - * - * @return void */ public function setFalMedia(ObjectStorage $falMedia): void { @@ -837,8 +801,6 @@ public function setFalMedia(ObjectStorage $falMedia): void * Add a Fal media file reference * * @param FileReference $falMedia - * - * @return void */ public function addFalMedia(FileReference $falMedia): void { @@ -951,8 +913,6 @@ public function getInternalurl(): string * Set internal url * * @param string $internalUrl internal url - * - * @return void */ public function setInternalurl($internalUrl): void { @@ -973,8 +933,6 @@ public function getExternalurl(): string * Set external url * * @param string $externalUrl external url - * - * @return void */ public function setExternalurl($externalUrl): void { @@ -995,8 +953,6 @@ public function getIstopnews(): bool * Set top news flag * * @param bool $istopnews top news flag - * - * @return void */ public function setIstopnews($istopnews): void { @@ -1017,8 +973,6 @@ public function getContentElements(): ?\TYPO3\CMS\Extbase\Persistence\ObjectStor * Set content element list * * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $contentElements content elements - * - * @return void */ public function setContentElements($contentElements): void { @@ -1029,8 +983,6 @@ public function setContentElements($contentElements): void * Adds a content element to the record * * @param \GeorgRinger\News\Domain\Model\TtContent $contentElement - * - * @return void */ public function addContentElement(TtContent $contentElement): void { @@ -1094,8 +1046,6 @@ public function getTags(): ?ObjectStorage * Set Tags * * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $tags tags - * - * @return void */ public function setTags($tags): void { @@ -1106,8 +1056,6 @@ public function setTags($tags): void * Adds a tag * * @param \GeorgRinger\News\Domain\Model\Tag $tag - * - * @return void */ public function addTag(Tag $tag): void { @@ -1118,8 +1066,6 @@ public function addTag(Tag $tag): void * Removes a tag * * @param \GeorgRinger\News\Domain\Model\Tag $tag - * - * @return void */ public function removeTag(Tag $tag): void { @@ -1140,8 +1086,6 @@ public function getPathSegment(): string * Set path segment * * @param string $pathSegment - * - * @return void */ public function setPathSegment($pathSegment): void { @@ -1162,8 +1106,6 @@ public function getCrdate(): DateTime * Set creation date * * @param DateTime $crdate - * - * @return void */ public function setCrdate($crdate): void { @@ -1214,8 +1156,6 @@ public function getTstamp(): DateTime * Set time stamp * * @param DateTime $tstamp time stamp - * - * @return void */ public function setTstamp($tstamp): void { @@ -1226,8 +1166,6 @@ public function setTstamp($tstamp): void * Set sys language * * @param int $sysLanguageUid - * - * @return void */ public function setSysLanguageUid($sysLanguageUid): void { @@ -1248,8 +1186,6 @@ public function getSysLanguageUid(): int * Set l10n parent * * @param int $l10nParent - * - * @return void */ public function setL10nParent($l10nParent): void { @@ -1310,8 +1246,6 @@ public function getCruserId(): int * Set cruser id * * @param int $cruserId id of creator user - * - * @return void */ public function setCruserId($cruserId): void { @@ -1332,8 +1266,6 @@ public function getEditlock(): int * Set edit lock flag * * @param int $editlock editlock flag - * - * @return void */ public function setEditlock($editlock): void { @@ -1354,7 +1286,6 @@ public function getHidden(): bool * Set hidden flag * * @param bool $hidden hidden flag - * @return void */ public function setHidden(bool $hidden): void { @@ -1375,8 +1306,6 @@ public function getDeleted(): bool * Set deleted flag * * @param bool $deleted deleted flag - * - * @return void */ public function setDeleted(bool $deleted): void { @@ -1386,7 +1315,7 @@ public function setDeleted(bool $deleted): void /** * Get start time * - * @return null|DateTime + * @return DateTime|null */ public function getStarttime(): ?DateTime { @@ -1397,8 +1326,6 @@ public function getStarttime(): ?DateTime * Set start time * * @param DateTime $starttime start time - * - * @return void */ public function setStarttime($starttime): void { @@ -1447,7 +1374,7 @@ public function getDayOfStarttime(): int /** * Get endtime * - * @return null|DateTime + * @return DateTime|null */ public function getEndtime(): ?DateTime { @@ -1458,8 +1385,6 @@ public function getEndtime(): ?DateTime * Set end time * * @param DateTime $endtime end time - * - * @return void */ public function setEndtime(DateTime $endtime): void { @@ -1519,8 +1444,6 @@ public function getFeGroup(): string * Set fe group * * @param string $feGroup comma separated list - * - * @return void */ public function setFeGroup($feGroup): void { @@ -1541,8 +1464,6 @@ public function getImportId(): string * Set import id * * @param string $importId import id - * - * @return void */ public function setImportId($importId): void { @@ -1563,8 +1484,6 @@ public function getSorting(): int * Set sorting * * @param int $sorting sorting - * - * @return void */ public function setSorting($sorting): void { @@ -1575,8 +1494,6 @@ public function setSorting($sorting): void * Set importSource * * @param string $importSource - * - * @return void */ public function setImportSource($importSource): void { @@ -1603,8 +1520,6 @@ public function getNotes(): string /** * @param string $notes - * - * @return void */ public function setNotes(string $notes): void { diff --git a/Classes/Domain/Model/NewsDefault.php b/Classes/Domain/Model/NewsDefault.php index 5a18150c31..92ef3d898d 100644 --- a/Classes/Domain/Model/NewsDefault.php +++ b/Classes/Domain/Model/NewsDefault.php @@ -1,14 +1,14 @@ generateQuery($demand, $respectEnableFields, $disableLanguageOverlayMode); - $versionInformation = GeneralUtility::makeInstance(Typo3Version::class); - if ($versionInformation->getMajorVersion() >= 11) { - $queryParser = GeneralUtility::makeInstance(Typo3DbQueryParser::class); - } else { - $queryParser = $this->objectManager->get(Typo3DbQueryParser::class); - } + $queryParser = GeneralUtility::makeInstance(Typo3DbQueryParser::class); $queryBuilder = $queryParser->convertQueryToDoctrineQueryBuilder($query); $queryParameters = $queryBuilder->getParameters(); $params = []; foreach ($queryParameters as $key => $value) { // prefix array keys with ':' - $params[':' . $key] = (is_numeric($value)) ? $value : "'" . $value . "'"; //all non numeric values have to be quoted + $params[':' . $key] = "'" . $value . "'"; unset($params[$key]); } // replace placeholders with real values @@ -146,7 +138,7 @@ protected function generateQuery(DemandInterface $demand, $respectEnableFields = if (!empty($constraints)) { $query->matching( - $query->logicalAnd($constraints) + $query->logicalAnd(...array_values($constraints)) ); } @@ -186,7 +178,6 @@ public function countDemanded(DemandInterface $demand, $respectEnableFields = tr ); } - $result = $query->execute(); - return $result->count(); + return $query->execute()->count(); } } diff --git a/Classes/Domain/Repository/AdministrationRepository.php b/Classes/Domain/Repository/AdministrationRepository.php index f0b2e9d86c..fa09783912 100644 --- a/Classes/Domain/Repository/AdministrationRepository.php +++ b/Classes/Domain/Repository/AdministrationRepository.php @@ -1,13 +1,14 @@ count('*') ->from('tx_news_domain_model_news') - ->execute()->fetchColumn(0); + ->executeQuery()->fetchOne(); $queryBuilder = $this->getQueryBuilder('sys_category_record_mm'); $count['category_relations'] = $queryBuilder @@ -38,7 +39,7 @@ public function getTotalCounts(): array 'tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) )) - ->execute()->fetchColumn(0); + ->executeQuery()->fetchOne(); if ($count['tx_news_domain_model_news'] > 0 && $count['category_relations']) { $count['_both'] = true; diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index 344d2201ce..7f643b4b58 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -1,13 +1,14 @@ getUid()] = [ 'item' => $category, - 'parent' => ($category->getParentcategory()) ? $category->getParentcategory()->getUid() : null + 'parent' => ($category->getParentcategory()) ? $category->getParentcategory()->getUid() : null, ]; } @@ -157,9 +158,7 @@ public function findByIdList(array $idList, array $ordering = [], $startingPoint } return $query->matching( - $query->logicalAnd( - $conditions - ) + $query->logicalAnd(...$conditions) )->execute(); } @@ -187,8 +186,6 @@ public function findChildren($parent) * * @param array $idList * return void - * - * @return void */ protected function overlayTranslatedCategoryIds(array &$idList): void { @@ -204,7 +201,7 @@ protected function overlayTranslatedCategoryIds(array &$idList): void $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)), $queryBuilder->expr()->in('l10n_parent', $queryBuilder->createNamedParameter($idList, Connection::PARAM_INT_ARRAY)) ) - ->execute()->fetchAll(); + ->executeQuery()->fetchAllAssociative(); $idList = $this->replaceCategoryIds($idList, $rows); } diff --git a/Classes/Domain/Repository/DemandedRepositoryInterface.php b/Classes/Domain/Repository/DemandedRepositoryInterface.php index 385838da6c..6e48f719d0 100644 --- a/Classes/Domain/Repository/DemandedRepositoryInterface.php +++ b/Classes/Domain/Repository/DemandedRepositoryInterface.php @@ -1,13 +1,14 @@ logicalOr($subCategoryConstraint); + $categoryConstraints[] = $query->logicalOr(...$subCategoryConstraint); } } else { $categoryConstraints[] = $query->contains('categories', $category); @@ -77,17 +80,17 @@ protected function createCategoryConstraint( if ($categoryConstraints) { switch (strtolower($conjunction)) { case 'or': - $constraint = $query->logicalOr($categoryConstraints); + $constraint = $query->logicalOr(...$categoryConstraints); break; case 'notor': - $constraint = $query->logicalNot($query->logicalOr($categoryConstraints)); + $constraint = $query->logicalNot($query->logicalOr(...$categoryConstraints)); break; case 'notand': - $constraint = $query->logicalNot($query->logicalAnd($categoryConstraints)); + $constraint = $query->logicalNot($query->logicalAnd(...$categoryConstraints)); break; case 'and': default: - $constraint = $query->logicalAnd($categoryConstraints); + $constraint = $query->logicalAnd(...$categoryConstraints); } } @@ -182,7 +185,7 @@ protected function createConstraintsFromDemand(QueryInterface $query, DemandInte // month & year OR year only if ($demand->getYear() > 0) { - if (null === $demand->getDateField()) { + if ($demand->getDateField() === null) { throw new \InvalidArgumentException('No Datefield is set, therefore no Datemenu is possible!'); } if ($demand->getMonth() > 0) { @@ -197,10 +200,11 @@ protected function createConstraintsFromDemand(QueryInterface $query, DemandInte $begin = mktime(0, 0, 0, 1, 1, $demand->getYear()); $end = mktime(23, 59, 59, 12, 31, $demand->getYear()); } - $constraints['datetime'] = $query->logicalAnd([ + $dateConstraints = [ $query->greaterThanOrEqual($demand->getDateField(), $begin), - $query->lessThanOrEqual($demand->getDateField(), $end) - ]); + $query->lessThanOrEqual($demand->getDateField(), $end), + ]; + $constraints['datetime'] = $query->logicalAnd(...$dateConstraints); } // Tags @@ -213,14 +217,14 @@ protected function createConstraintsFromDemand(QueryInterface $query, DemandInte $subConstraints[] = $query->contains('tags', $singleTag); } if (count($subConstraints) > 0) { - $constraints['tags'] = $query->logicalOr($subConstraints); + $constraints['tags'] = $query->logicalOr(...$subConstraints); } } // Search $searchConstraints = $this->getSearchConstraints($query, $demand); if (!empty($searchConstraints)) { - $constraints['search'] = $query->logicalAnd($searchConstraints); + $constraints['search'] = $query->logicalAnd(...$searchConstraints); } // Exclude already displayed @@ -252,7 +256,7 @@ protected function createConstraintsFromDemand(QueryInterface $query, DemandInte // Clean not used constraints foreach ($constraints as $key => $value) { - if (null === $value) { + if ($value === null) { unset($constraints[$key]); } } @@ -375,16 +379,22 @@ public function countByDate(DemandInterface $demand): array $field = $demand->getDateField(); $field = empty($field) ? 'datetime' : $field; - $sql = 'SELECT MONTH(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND ) AS "_Month",' . - ' YEAR(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND) AS "_Year" ,' . - ' count(MONTH(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND )) as count_month,' . - ' count(YEAR(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND)) as count_year' . - ' FROM tx_news_domain_model_news ' . substr($sql, strpos($sql, 'WHERE ')); - $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable('tx_news_domain_model_news'); + $isPostgres = $connection->getDatabasePlatform() instanceof PostgreSQLPlatform; + if ($isPostgres) { + $sql = 'SELECT count(*), date_trunc(\'year\', to_timestamp(' . $field . '/1)::date) as _year, date_trunc(\'month\', to_timestamp(' . $field . '/1)::date) as _MONTH +from tx_news_domain_model_news ' . substr($sql, strpos($sql, 'WHERE ')); + } else { + $sql = 'SELECT MONTH(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND ) AS "_month",' . + ' YEAR(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND) AS "_year" ,' . + ' count(MONTH(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND )) as count_month,' . + ' count(YEAR(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND)) as count_year' . + ' FROM tx_news_domain_model_news ' . substr($sql, strpos($sql, 'WHERE ')); + } - if (TYPO3_MODE === 'FE') { + if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { + // @extensionScannerIgnoreLine $sql .= $GLOBALS['TSFE']->sys_page->enableFields('tx_news_domain_model_news'); } else { $expressionBuilder = $connection @@ -399,14 +409,19 @@ public function countByDate(DemandInterface $demand): array if ($orderDirection !== 'desc' && $orderDirection !== 'asc') { $orderDirection = 'asc'; } - $sql .= ' GROUP BY _Month, _Year ORDER BY _Year ' . $orderDirection . ', _Month ' . $orderDirection; + $sql .= ' GROUP BY _month, _year ORDER BY _year ' . $orderDirection . ', _month ' . $orderDirection; - $res = $connection->query($sql); - while ($row = $res->fetch()) { - $month = strlen($row['_Month']) === 1 ? ('0' . $row['_Month']) : $row['_Month']; - $data['single'][$row['_Year']][$month] = $row['count_month']; - } + $res = $connection->executeQuery($sql); + while ($row = $res->fetchAssociative()) { + if ($isPostgres) { + $splitMonth = explode('-', $row['_month']); + $data['single'][$splitMonth[0]][$splitMonth[1]] = $row['count']; + } else { + $month = strlen($row['_month']) === 1 ? ('0' . $row['_month']) : $row['_month']; + $data['single'][$row['_year']][$month] = $row['count_month']; + } + } // Add totals if (is_array($data['single'])) { foreach ($data['single'] as $year => $months) { @@ -441,8 +456,6 @@ protected function getSearchConstraints(QueryInterface $query, DemandInterface $ $searchSubject = $searchObject->getSubject(); if (!empty($searchSubject)) { - $queryBuilder = $this->getQueryBuilder('tx_news_domain_model_news'); - $searchFields = GeneralUtility::trimExplode(',', $searchObject->getFields(), true); $searchConstraints = []; @@ -459,19 +472,17 @@ protected function getSearchConstraints(QueryInterface $query, DemandInterface $ $subConstraints[] = $query->like($field, '%' . $searchSubjectSplittedPart . '%'); } } - $searchConstraints[] = $query->logicalAnd($subConstraints); + $searchConstraints[] = $query->logicalAnd(...$subConstraints); } if (count($searchConstraints)) { - $constraints[] = $query->logicalOr($searchConstraints); + $constraints[] = $query->logicalOr(...$searchConstraints); } } else { - if (!empty($searchSubject)) { - foreach ($searchFields as $field) { - $searchConstraints[] = $query->like($field, '%' . $searchSubject . '%'); - } + foreach ($searchFields as $field) { + $searchConstraints[] = $query->like($field, '%' . $searchSubject . '%'); } - if (count($searchConstraints)) { - $constraints[] = $query->logicalOr($searchConstraints); + if (count($searchConstraints) > 0) { + $constraints[] = $query->logicalOr(...$searchConstraints); } } } diff --git a/Classes/Domain/Repository/TagRepository.php b/Classes/Domain/Repository/TagRepository.php index dad7426b5c..87959048d5 100644 --- a/Classes/Domain/Repository/TagRepository.php +++ b/Classes/Domain/Repository/TagRepository.php @@ -1,13 +1,14 @@ emSettings = GeneralUtility::makeInstance(EmConfiguration::class); $this->persistenceManager = $persistenceManager; - $this->objectManager = $objectManager; $this->categoryRepository = $categoryRepository; $this->eventDispatcher = $eventDispatcher; } @@ -100,7 +92,6 @@ protected function filesAreEqual($file1, $file2): bool * Find a existing file by its hash * * @param string $hash - * * @return File|ProcessedFile|null */ protected function findFileByHash($hash) @@ -143,29 +134,16 @@ protected function getImportFolder(): Folder return $this->importFolder; } - /** - * Returns an instance of the FileIndexRepository - * - * @return FileIndexRepository - */ protected function getFileIndexRepository(): FileIndexRepository { - return FileIndexRepository::getInstance(); + return GeneralUtility::makeInstance(FileIndexRepository::class); } - /** - * Get resource storage - * - * @return ResourceStorage - */ protected function getResourceStorage(): ResourceStorage { return $this->getResourceFactory()->getStorageObject($this->emSettings->getStorageUidImporter()); } - /** - * @return ResourceFactory - */ protected function getResourceFactory(): ResourceFactory { /** @var ResourceFactory $resourceFactory */ diff --git a/Classes/Domain/Service/CategoryImportService.php b/Classes/Domain/Service/CategoryImportService.php index 0992160e5c..3bed122e61 100644 --- a/Classes/Domain/Service/CategoryImportService.php +++ b/Classes/Domain/Service/CategoryImportService.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * This file is part of the "news" Extension for TYPO3 CMS. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + namespace GeorgRinger\News\Domain\Service; use GeorgRinger\News\Domain\Model\Category; @@ -12,15 +19,8 @@ use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; -/** - * This file is part of the "news" Extension for TYPO3 CMS. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - */ class CategoryImportService extends AbstractImportService { public const ACTION_SET_PARENT_CATEGORY = 1; @@ -31,11 +31,10 @@ class CategoryImportService extends AbstractImportService */ public function __construct( PersistenceManager $persistenceManager, - ObjectManager $objectManager, CategoryRepository $categoryRepository, EventDispatcherInterface $eventDispatcher ) { - parent::__construct($persistenceManager, $objectManager, $categoryRepository, $eventDispatcher); + parent::__construct($persistenceManager, $categoryRepository, $eventDispatcher); } public function import(array $importArray): void @@ -51,7 +50,7 @@ public function import(array $importArray): void 'category' => $category, 'importItem' => $importItem, 'action' => self::ACTION_CREATE_L10N_CHILDREN_CATEGORY, - 'titleLanguageOverlay' => $importItem['title_lang_ol'] + 'titleLanguageOverlay' => $importItem['title_lang_ol'], ]; } @@ -59,7 +58,7 @@ public function import(array $importArray): void $this->postPersistQueue[$importItem['import_id']] = [ 'category' => $category, 'action' => self::ACTION_SET_PARENT_CATEGORY, - 'parentCategoryOriginUid' => $importItem['parentcategory'] + 'parentCategoryOriginUid' => $importItem['parentcategory'], ]; } } @@ -156,7 +155,6 @@ protected function hydrateCategory(array $importItem): Category */ protected function setFileRelationFromImage(Category $category, string $image): void { - // get fileObject by given identifier (file UID, combined identifier or path/filename) try { $newImage = $this->getResourceFactory()->retrieveFileOrFolderObject($image); @@ -191,7 +189,6 @@ protected function setFileRelationFromImage(Category $category, string $image): if ($newImage) { // file not inside a storage then search for existing file or copy the one form storage 0 to the import folder if ($newImage->getStorage()->getUid() === 0) { - // search DB for same file based on hash (to prevent duplicates) $existingFile = $this->findFileByHash($newImage->getSha1()); diff --git a/Classes/Domain/Service/NewsImportService.php b/Classes/Domain/Service/NewsImportService.php index 5ef9e33052..8ffc2014a2 100644 --- a/Classes/Domain/Service/NewsImportService.php +++ b/Classes/Domain/Service/NewsImportService.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * This file is part of the "news" Extension for TYPO3 CMS. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + namespace GeorgRinger\News\Domain\Service; use GeorgRinger\News\Domain\Model\FileReference; @@ -18,16 +25,9 @@ use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; -/** - * This file is part of the "news" Extension for TYPO3 CMS. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - */ class NewsImportService extends AbstractImportService { public const ACTION_IMPORT_L10N_OVERLAY = 1; @@ -52,13 +52,12 @@ class NewsImportService extends AbstractImportService */ public function __construct( PersistenceManager $persistenceManager, - ObjectManager $objectManager, CategoryRepository $categoryRepository, EventDispatcherInterface $eventDispatcher, NewsRepository $newsRepository, TtContentRepository $ttContentRepository ) { - parent::__construct($persistenceManager, $objectManager, $categoryRepository, $eventDispatcher); + parent::__construct($persistenceManager, $categoryRepository, $eventDispatcher); $this->newsRepository = $newsRepository; $this->ttContentRepository = $ttContentRepository; @@ -205,7 +204,6 @@ protected function hydrateNewsRecord( /** @var $media FileReference */ if (!$media = $this->getIfFalRelationIfAlreadyExists($news->getFalMedia(), $file)) { - // file not inside a storage copy the one form storage 0 to the import folder if ($file->getStorage()->getUid() === 0) { $file = $this->getResourceStorage()->copyFile($file, $this->getImportFolder()); @@ -229,7 +227,6 @@ protected function hydrateNewsRecord( // related files if (is_array($importItem['related_files'] ?? false)) { foreach ($importItem['related_files'] as $fileItem) { - // get fileObject by given identifier (file UID, combined identifier or path/filename) try { $file = $this->getResourceFactory()->retrieveFileOrFolderObject($fileItem['file']); @@ -252,7 +249,6 @@ protected function hydrateNewsRecord( /** @var $relatedFile FileReference */ if (!$relatedFile = $this->getIfFalRelationIfAlreadyExists($news->getFalRelatedFiles(), $file)) { - // file not inside a storage copy the one form storage 0 to the import folder if ($file->getStorage()->getUid() === 0) { $file = $this->getResourceStorage()->copyFile($file, $this->getImportFolder()); @@ -306,7 +302,7 @@ public function import(array $importData, array $importItemOverwrite = [], array $this->postPersistQueue[$importItem['import_id']] = [ 'action' => self::ACTION_IMPORT_L10N_OVERLAY, 'category' => null, - 'importItem' => $importItem + 'importItem' => $importItem, ]; continue; } diff --git a/Classes/Event/CategoryImportPostHydrateEvent.php b/Classes/Event/CategoryImportPostHydrateEvent.php index 45722926cf..e60f8be200 100644 --- a/Classes/Event/CategoryImportPostHydrateEvent.php +++ b/Classes/Event/CategoryImportPostHydrateEvent.php @@ -1,16 +1,17 @@ getTable() === 'tt_content' && $event->getPageId() > 0) { + // Get page record base on page uid + $pageRecord = BackendUtility::getRecord('pages', $event->getPageId(), 'uid', " AND doktype='254' AND module='news'"); + + if (is_array($pageRecord)) { + $tsConfig = BackendUtility::getPagesTSconfig($event->getPageId()); + + if ((int)($tsConfig['tx_news.']['showContentElementsInNewsSysFolder'] ?? 0) === 1) { + return; + } + + // Only hide elements which are inline, allowing for standard + // elements to show + $event->getQueryBuilder()->andWhere( + $event->getQueryBuilder()->expr()->eq('tx_news_related_news', $event->getQueryBuilder()->createNamedParameter(0, \PDO::PARAM_INT)) + ); + + if (self::$count === 0) { + $this->addFlashMessage(); + } + + self::$count++; + } + } + } + + /** + * Render flash message to inform user + * that no elements belonging to news articles + * are rendered in the page module + */ + protected function addFlashMessage(): void + { + $message = GeneralUtility::makeInstance( + FlashMessage::class, + $this->getLanguageService()->sL('LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:hiddenContentElements.description'), + '', + ContextualFeedbackSeverity::INFO + ); + $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); + $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); + $defaultFlashMessageQueue->enqueue($message); + } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } +} diff --git a/Classes/Event/Listener/ModifyFileReferenceControlsEventListener.php b/Classes/Event/Listener/ModifyFileReferenceControlsEventListener.php new file mode 100644 index 0000000000..c729158da9 --- /dev/null +++ b/Classes/Event/Listener/ModifyFileReferenceControlsEventListener.php @@ -0,0 +1,50 @@ +getRecord(); + $previewSetting = (int)(is_array($childRecord['showinpreview'] ?? false) ? $childRecord['showinpreview'][0] : ($childRecord['showinpreview'] ?? 0)); + if ($event->getForeignTable() === 'sys_file_reference' && $previewSetting > 0) { + $ll = 'LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:'; + + $iconFactory = GeneralUtility::makeInstance(IconFactory::class); + $extensionConfiguration = GeneralUtility::makeInstance(EmConfiguration::class); + + if ($extensionConfiguration->isAdvancedMediaPreview()) { + if ($previewSetting === 1) { + $icon = $iconFactory->getIcon('ext-news-doublecheck', Icon::SIZE_SMALL); + $label = $GLOBALS['LANG']->sL($ll . 'tx_news_domain_model_media.showinviews.1'); + $event->setControl('ext-news-preview', ' ' . $icon . ''); + } elseif ($previewSetting === 2) { + $icon = $iconFactory->getIcon('actions-check', Icon::SIZE_SMALL); + $label = $GLOBALS['LANG']->sL($ll . 'tx_news_domain_model_media.showinviews.2'); + $event->setControl('ext-news-preview', ' ' . $icon . ''); + } + } elseif ($previewSetting === 1) { + $icon = $iconFactory->getIcon('actions-check', Icon::SIZE_SMALL); + $label = $GLOBALS['LANG']->sL($ll . 'tx_news_domain_model_media.showinpreview'); + $event->setControl('ext-news-preview', ' ' . $icon . ''); + } + } + } +} diff --git a/Classes/Event/ModifyCacheTagsFromDemandEvent.php b/Classes/Event/ModifyCacheTagsFromDemandEvent.php index 557ee2ce4e..cc127757a5 100644 --- a/Classes/Event/ModifyCacheTagsFromDemandEvent.php +++ b/Classes/Event/ModifyCacheTagsFromDemandEvent.php @@ -2,16 +2,17 @@ declare(strict_types=1); -namespace GeorgRinger\News\Event; - -use GeorgRinger\News\Domain\Model\DemandInterface; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Event; + +use GeorgRinger\News\Domain\Model\DemandInterface; + final class ModifyCacheTagsFromDemandEvent { /** diff --git a/Classes/Event/ModifyCacheTagsFromNewsEvent.php b/Classes/Event/ModifyCacheTagsFromNewsEvent.php index a15d795f36..3189eb3469 100644 --- a/Classes/Event/ModifyCacheTagsFromNewsEvent.php +++ b/Classes/Event/ModifyCacheTagsFromNewsEvent.php @@ -2,16 +2,17 @@ declare(strict_types=1); -namespace GeorgRinger\News\Event; - -use GeorgRinger\News\Domain\Model\News; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Event; + +use GeorgRinger\News\Domain\Model\News; + final class ModifyCacheTagsFromNewsEvent { /** diff --git a/Classes/Event/NewsCheckPidOfNewsRecordFailedInDetailActionEvent.php b/Classes/Event/NewsCheckPidOfNewsRecordFailedInDetailActionEvent.php index efde135098..400b622629 100644 --- a/Classes/Event/NewsCheckPidOfNewsRecordFailedInDetailActionEvent.php +++ b/Classes/Event/NewsCheckPidOfNewsRecordFailedInDetailActionEvent.php @@ -1,17 +1,18 @@ 0) { - // Get page record base on page uid $pageRecord = BackendUtility::getRecord('pages', $pageId, 'uid', " AND doktype='254' AND module='news'"); diff --git a/Classes/Hooks/Backend/RecordListQueryHook.php b/Classes/Hooks/Backend/RecordListQueryHook.php index 2262aa33d7..3e02680c77 100644 --- a/Classes/Hooks/Backend/RecordListQueryHook.php +++ b/Classes/Hooks/Backend/RecordListQueryHook.php @@ -1,13 +1,14 @@ recordListConstraint = $recordListConstraint; } - /** - * @return void - */ public function modifyQuery( array &$parameters, string $table, diff --git a/Classes/Hooks/DataHandlerHook.php b/Classes/Hooks/DataHandlerHook.php index a8b846c48d..2e11a35d80 100644 --- a/Classes/Hooks/DataHandlerHook.php +++ b/Classes/Hooks/DataHandlerHook.php @@ -1,13 +1,14 @@ 'orderBy,orderDirection,categories,categoryConjunction,includeSubCategories, - archiveRestriction,timeRestriction,timeRestrictionHigh,topNewsRestriction, - dateField,selectedList', - 'additional' => 'limit,offset,hidePagination,topNewsFirst,listPid,list.paginate.itemsPerPage', - 'template' => 'cropMaxCharacters' - ]; - - /** - * Fields which are removed in list view - * - * @var array - */ - public $removedFieldsInListView = [ - 'sDEF' => 'dateField,singleNews,previewHiddenRecords,selectedList', - 'additional' => '', - 'template' => '' - ]; - - /** - * Fields which are removed in selected list view - * - * @var array - */ - public $removedFieldsInSelectedListView = [ - 'sDEF' => 'categories,categoryConjunction,includeSubCategories, - archiveRestriction,timeRestriction,timeRestrictionHigh,topNewsRestriction, - startingpoint,recursive,dateField,singleNews,previewHiddenRecords, - previewHiddenRecords,startingpoint,recursive', - 'additional' => 'tags,limit,offset,hidePagination,topNewsFirst,backPid,excludeAlreadyDisplayedNews, - list.paginate.itemsPerPage,disableOverrideDemand', - 'template' => '' - ]; - - /** - * Fields which are removed in dateMenu view - * - * @var array - */ - public $removedFieldsInDateMenuView = [ - 'sDEF' => 'orderBy,singleNews,selectedList', - 'additional' => 'limit,offset,hidePagination,topNewsFirst,backPid,previewHiddenRecords,excludeAlreadyDisplayedNews, - list.paginate.itemsPerPage', - 'template' => 'cropMaxCharacters,media.maxWidth,media.maxHeight' - ]; - - /** - * Fields which are removed in search form view - * - * @var array - */ - public $removedFieldsInSearchFormView = [ - 'sDEF' => 'orderBy,orderDirection,categories,categoryConjunction,includeSubCategories, - archiveRestriction,timeRestriction,timeRestrictionHigh,topNewsRestriction, - startingpoint,recursive,dateField,singleNews,previewHiddenRecords,selectedList', - 'additional' => 'limit,offset,hidePagination,topNewsFirst,detailPid,backPid,excludeAlreadyDisplayedNews, - list.paginate.itemsPerPage', - 'template' => 'cropMaxCharacters,media.maxWidth,media.maxHeight' - ]; - - /** - * Fields which are removed in category list view - * - * @var array - */ - public $removedFieldsInCategoryListView = [ - 'sDEF' => 'orderBy,orderDirection,categoryConjunction,includeSubCategories, - archiveRestriction,timeRestriction,timeRestrictionHigh,topNewsRestriction, - recursive,dateField,singleNews,previewHiddenRecords,selectedList', - 'additional' => 'limit,offset,hidePagination,topNewsFirst,detailPid,backPid,excludeAlreadyDisplayedNews, - list.paginate.itemsPerPage', - 'template' => 'cropMaxCharacters,media.maxWidth,media.maxHeight' - ]; - - /** - * Fields which are removed in tag list view - * - * @var array - */ - public $removedFieldsInTagListView = [ - 'sDEF' => 'categories,categoryConjunction,includeSubCategories, - archiveRestriction,timeRestriction,timeRestrictionHigh,topNewsRestriction, - dateField,singleNews,previewHiddenRecords,selectedList', - 'additional' => 'limit,offset,hidePagination,topNewsFirst,detailPid,backPid,excludeAlreadyDisplayedNews, - list.paginate.itemsPerPage', - 'template' => 'cropMaxCharacters,media.maxWidth,media.maxHeight' - ]; - - /** @var EmConfiguration */ - protected $configuration; - - /** - * BackendUtility constructor. - * @param EmConfiguration $configuration - */ - public function __construct( - ) { - $this->configuration = GeneralUtility::makeInstance(EmConfiguration::class); - } - - /** - * @param array $dataStructure - * @param array $identifier - * - * @return array|string - */ - public function parseDataStructureByIdentifierPostProcess(array $dataStructure, array $identifier) - { - if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content' && $identifier['dataStructureKey'] === 'news_pi1,list') { - $getVars = GeneralUtility::_GET('edit'); - if (isset($getVars['tt_content']) && is_array($getVars['tt_content'])) { - $item = array_keys($getVars['tt_content']); - $recordId = (int)$item[0]; - - if (($getVars['tt_content'][$recordId] ?? '') === 'new') { - $fakeRow = [ - 'uid' => 'NEW123' - ]; - $this->updateFlexforms($dataStructure, $fakeRow); - } else { - $row = BackendUtilityCore::getRecord('tt_content', $recordId); - if (is_array($row)) { - $this->updateFlexforms($dataStructure, $row); - } - } - } - } - return $dataStructure; - } - - /** - * Update flexform configuration if a action is selected - * - * @param array|string &$dataStructure flexform structure - * @param array $row row of current record - * @param array $dataStructure - * - * @return void - */ - protected function updateFlexforms(array &$dataStructure, array $row): void - { - $selectedView = ''; - $flexformSelection = []; - if (isset($row['pi_flexform'])) { - // get the first selected action - if (is_string($row['pi_flexform'])) { - $flexformSelection = GeneralUtility::xml2array($row['pi_flexform']); - } else { - $flexformSelection = $row['pi_flexform']; - } - } - if (is_array($flexformSelection) && isset($flexformSelection['data'])) { - $selectedView = $flexformSelection['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'] ?? ''; - if (!empty($selectedView)) { - $actionParts = GeneralUtility::trimExplode(';', $selectedView, true); - $selectedView = $actionParts[0]; - } - - // new plugin element - } elseif (str_starts_with((string)$row['uid'], 'NEW')) { - // use List as starting view - $selectedView = 'News->list'; - } - - if (!empty($selectedView)) { - // Modify the flexform structure depending on the first found action - switch ($selectedView) { - case 'News->list': - case 'News->searchResult': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInListView); - break; - case 'News->detail': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInDetailView); - break; - case 'News->selectedList': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInSelectedListView); - break; - case 'News->searchForm': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInSearchFormView); - break; - case 'News->dateMenu': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInDateMenuView); - break; - case 'Category->list': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInCategoryListView); - break; - case 'Tag->list': - $this->deleteFromStructure($dataStructure, $this->removedFieldsInTagListView); - break; - default: - } - - if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Hooks/BackendUtility.php']['updateFlexforms'] ?? []) { - $params = [ - 'selectedView' => $selectedView, - 'dataStructure' => &$dataStructure, - ]; - foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Hooks/BackendUtility.php']['updateFlexforms'] as $reference) { - GeneralUtility::callUserFunction($reference, $params, $this); - } - } - } - } - - /** - * Add category restriction to flexforms - * - * @param array $structure - * - * @return void - */ - protected function addCategoryConstraints(&$structure): void - { - $categoryRestrictionSetting = $this->configuration->getCategoryRestriction(); - $categoryRestriction = ''; - switch ($categoryRestrictionSetting) { - case 'current_pid': - $categoryRestriction = ' AND sys_category.pid=###CURRENT_PID### '; - break; - case 'siteroot': - $categoryRestriction = ' AND sys_category.pid IN (###SITEROOT###) '; - break; - case 'page_tsconfig': - $categoryRestriction = ' AND sys_category.pid IN (###PAGE_TSCONFIG_IDLIST###) '; - break; - } - - if (!empty($categoryRestriction) && isset($structure['sheets']['sDEF']['ROOT']['el']['settings.categories'])) { - $structure['sheets']['sDEF']['ROOT']['el']['settings.categories']['TCEforms']['config']['foreign_table_where'] = $categoryRestriction . $structure['sheets']['sDEF']['ROOT']['el']['settings.categories']['TCEforms']['config']['foreign_table_where']; - } - } - - /** - * Remove fields from flexform structure - * - * @param array &$dataStructure flexform structure - * @param array $fieldsToBeRemoved fields which need to be removed - * - * @return void - */ - protected function deleteFromStructure(array &$dataStructure, array $fieldsToBeRemoved): void - { - foreach ($fieldsToBeRemoved as $sheetName => $sheetFields) { - $fieldsInSheet = GeneralUtility::trimExplode(',', $sheetFields, true); - - foreach ($fieldsInSheet as $fieldName) { - unset($dataStructure['sheets'][$sheetName]['ROOT']['el']['settings.' . $fieldName]); - } - } - } - - /** - * @param int $pageId - * @return bool - */ - protected function enabledInTsConfig($pageId): bool - { - $tsConfig = BackendUtilityCore::getPagesTSconfig($pageId); - if (isset($tsConfig['tx_news.']['categoryRestrictionForFlexForms'])) { - return (bool)$tsConfig['tx_news.']['categoryRestrictionForFlexForms']; - } - return false; - } -} diff --git a/Classes/Hooks/InlineElementHook.php b/Classes/Hooks/InlineElementHook.php index 409cd33329..a4ceb5a5ba 100644 --- a/Classes/Hooks/InlineElementHook.php +++ b/Classes/Hooks/InlineElementHook.php @@ -1,15 +1,16 @@ getLanguageService()->sL($layout[0])), - $layout[1] + $layout[1], ]; array_push($config['items'], $additionalLayout); } @@ -99,8 +96,6 @@ protected function reduceTemplateLayouts($templateLayouts, $currentColPos): arra * needs different ones then a news action * * @param array &$config configuration array - * - * @return void */ public function user_orderBy(array &$config): void { @@ -111,12 +106,12 @@ public function user_orderBy(array &$config): void $flexformConfig = GeneralUtility::xml2array($row['pi_flexform']); // check if there is a flexform configuration - if (isset($flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'])) { - $selectedActionList = $flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'] ?? ''; - // check for selected action - if (str_starts_with($selectedActionList, 'Category')) { + if (isset($flexformConfig['data']['sDEF']['lDEF'])) { + $selectedPlugin = strtolower($row['CType']) ?? ''; + // check for selected plugin + if ($selectedPlugin === 'news_categorylist') { $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByCategory']; - } elseif (str_starts_with($selectedActionList, 'Tag')) { + } elseif ($selectedPlugin === 'news_taglist') { $this->removeNonValidOrderFields($config, 'tx_news_domain_model_tag'); $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByTag']; } else { @@ -150,8 +145,6 @@ public function user_orderBy(array &$config): void * * @param array $config tca items * @param string $tableName table name - * - * @return void */ protected function removeNonValidOrderFields(array &$config, $tableName): void { @@ -164,45 +157,11 @@ protected function removeNonValidOrderFields(array &$config, $tableName): void } } - /** - * Modifies the selectbox of available actions - * - * @param array &$config - * - * @return void - */ - public function user_switchableControllerActions(array &$config): void - { - if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['list'])) { - $configuration = (int)$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['list']; - switch ($configuration) { - case 1: - $this->removeActionFromList($config, 'News->list'); - break; - case 2: - $this->removeActionFromList($config, 'News->list;News->detail'); - break; - default: - } - } - - // Add additional actions - if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['newItems']) - && is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['newItems']) - ) { - foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['newItems'] as $key => $label) { - array_push($config['items'], [$this->getLanguageService()->sL($label), $key, '']); - } - } - } - /** * Remove given action from switchableControllerActions * * @param array $config available items * @param string $action action to be removed - * - * @return void */ private function removeActionFromList(array &$config, $action): void { @@ -256,16 +215,6 @@ public function user_categoryOverlay(): string */ protected function getAllLanguages(): array { - $versionInformation = GeneralUtility::makeInstance(Typo3Version::class); - if ($versionInformation->getMajorVersion() === 10) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) - ->getQueryBuilderForTable('sys_language'); - return $queryBuilder->select('*') - ->from('sys_language') - ->orderBy('sorting') - ->execute() - ->fetchAll(); - } $siteLanguages = []; foreach (GeneralUtility::makeInstance(SiteFinder::class)->getAllSites() as $site) { foreach ($site->getAllLanguages() as $languageId => $language) { diff --git a/Classes/Hooks/Labels.php b/Classes/Hooks/Labels.php index ebed65f42a..f4853005c7 100644 --- a/Classes/Hooks/Labels.php +++ b/Classes/Hooks/Labels.php @@ -1,13 +1,14 @@ Page module + * Render selected options of plugin in Web>Page module */ -class PageLayoutView +class PluginPreviewRenderer extends StandardContentPreviewRenderer { - /** - * Extension key - * - * @var string - */ - public const KEY = 'news'; - - /** - * Path to the locallang file - * - * @var string - */ - public const LLPATH = 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:'; - - /** - * Max shown settings - */ - public const SETTINGS_IN_PREVIEW = 7; + protected const LLPATH = 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:'; + protected const SETTINGS_IN_PREVIEW = 7; /** * Table information - * - * @var array */ - public $tableData = []; + public array $tableData = []; /** * Flexform information - * - * @var array */ - public $flexformData = []; + public array $flexformData = []; /** * @var IconFactory @@ -65,118 +49,89 @@ class PageLayoutView /** @var TemplateLayout $templateLayoutsUtility */ protected $templateLayoutsUtility; - /** - * PageLayoutView constructor. - * @param TemplateLayout $templateLayout - * @param IconFactory $iconFactory - */ - public function __construct( - TemplateLayout $templateLayout, - IconFactory $iconFactory - ) { - $this->templateLayoutsUtility = $templateLayout; - $this->iconFactory = $iconFactory; + public function __construct() + { + $this->templateLayoutsUtility = GeneralUtility::makeInstance(TemplateLayout::class); + $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); } - /** - * Returns information about this extension's pi1 plugin - * - * @param array $params Parameters to the hook - * @return string Information about pi1 plugin - */ - public function getExtensionSummary(array $params): string + public function renderPageModulePreviewContent(GridColumnItem $item): string { + $row = $item->getRecord(); $actionTranslationKey = $result = ''; - $header = '' . htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'pi1_title')) . ''; - if ($params['row']['list_type'] == self::KEY . '_pi1') { - $this->tableData = []; - $this->flexformData = GeneralUtility::xml2array($params['row']['pi_flexform']); - - // if flexform data is found - $actions = $this->getFieldFromFlexform('switchableControllerActions'); - if (!empty($actions)) { - $actionList = GeneralUtility::trimExplode(';', $actions); - - // translate the first action into its translation - $actionTranslationKey = strtolower(str_replace('->', '_', $actionList[0])); - $actionTranslation = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.' . $actionTranslationKey); - - $header .= '
' . htmlspecialchars($actionTranslation) . ''; - } else { - $header .= $this->generateCallout($this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.not_configured')); + $this->tableData = []; + $flexforms = GeneralUtility::xml2array($row['pi_flexform']); + if (is_string($flexforms)) { + return 'ERROR: ' . htmlspecialchars($flexforms); + } + $this->flexformData = (array)$flexforms; + + if (!empty($this->flexformData)) { + switch ($row['CType']) { + case 'news_pi1': + case 'news_newsliststicky': + $this->getStartingPoint(); + $this->getCategorySettings(); + $this->getDetailPidSetting(); + $this->getTimeRestrictionSetting(); + $this->getTemplateLayoutSettings($row['pid']); + $this->getArchiveSettings(); + $this->getTopNewsRestrictionSetting(); + $this->getOrderSettings(); + $this->getOffsetLimitSettings(); + $this->getListPidSetting(); + $this->getTagRestrictionSetting(); + break; + case 'news_newsselectedlist': + $this->getSelectedListSetting(); + $this->getOrderSettings(); + break; + case 'news_newsdetail': + $this->getSingleNewsSettings(); + $this->getDetailPidSetting(); + $this->getTemplateLayoutSettings($row['pid']); + break; + case 'news_newsdatemenu': + $this->getStartingPoint(); + $this->getTimeRestrictionSetting(); + $this->getTopNewsRestrictionSetting(); + $this->getArchiveSettings(); + $this->getDateMenuSettings(); + $this->getCategorySettings(); + $this->getTemplateLayoutSettings($row['pid']); + break; + case 'news_categorylist': + $this->getCategorySettings(false); + $this->getTemplateLayoutSettings($row['pid']); + break; + case 'news_taglist': + $this->getStartingPoint(); + $this->getListPidSetting(); + $this->getOrderSettings(); + $this->getTemplateLayoutSettings($row['pid']); + break; + default: + $this->getTemplateLayoutSettings($row['pid']); } - if (is_array($this->flexformData)) { - switch ($actionTranslationKey) { - case 'news_list': - $this->getStartingPoint(); - $this->getCategorySettings(); - $this->getDetailPidSetting(); - $this->getTimeRestrictionSetting(); - $this->getTemplateLayoutSettings($params['row']['pid']); - $this->getArchiveSettings(); - $this->getTopNewsRestrictionSetting(); - $this->getOrderSettings(); - $this->getOffsetLimitSettings(); - $this->getListPidSetting(); - $this->getTagRestrictionSetting(); - break; - case 'news_selectedlist': - $this->getSelectedListSetting(); - $this->getOrderSettings(); - break; - case 'news_detail': - $this->getSingleNewsSettings(); - $this->getDetailPidSetting(); - $this->getTemplateLayoutSettings($params['row']['pid']); - break; - case 'news_datemenu': - $this->getStartingPoint(); - $this->getTimeRestrictionSetting(); - $this->getTopNewsRestrictionSetting(); - $this->getArchiveSettings(); - $this->getDateMenuSettings(); - $this->getCategorySettings(); - $this->getTemplateLayoutSettings($params['row']['pid']); - break; - case 'category_list': - $this->getCategorySettings(false); - $this->getTemplateLayoutSettings($params['row']['pid']); - break; - case 'tag_list': - $this->getStartingPoint(); - $this->getListPidSetting(); - $this->getOrderSettings(); - $this->getTemplateLayoutSettings($params['row']['pid']); - break; - default: - $this->getTemplateLayoutSettings($params['row']['pid']); - } - - if ($hooks = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['GeorgRinger\\News\\Hooks\\PageLayoutView']['extensionSummary'] ?? []) { - $params['action'] = $actionTranslationKey; - foreach ($hooks as $reference) { - GeneralUtility::callUserFunction($reference, $params, $this); - } + if ($hooks = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['GeorgRinger\\News\\Hooks\\PluginPreviewRenderer']['extensionSummary'] ?? []) { + $params['action'] = $actionTranslationKey; + foreach ($hooks as $reference) { + GeneralUtility::callUserFunction($reference, $params, $this); } + } - // for all views - $this->getOverrideDemandSettings(); + // for all views + $this->getOverrideDemandSettings(); - $result = $this->renderSettingsAsTable($header, $params['row']['uid'] ?? 0); - } + $result = $this->renderSettingsAsTable($header, $row['uid'] ?? 0); } return $result; } - /** - * Render archive settings - * - * @return void - */ public function getArchiveSettings(): void { $archive = $this->getFieldFromFlexform('settings.archiveRestriction'); @@ -184,16 +139,11 @@ public function getArchiveSettings(): void if (!empty($archive)) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.archiveRestriction'), - $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.archiveRestriction.' . $archive) + $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.archiveRestriction.' . $archive), ]; } } - /** - * Render single news settings - * - * @return void - */ public function getSingleNewsSettings(): void { $singleNewsRecord = (int)$this->getFieldFromFlexform('settings.singleNews'); @@ -223,16 +173,11 @@ public function getSingleNewsSettings(): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.singleNews'), - $content + $content, ]; } } - /** - * Render single news settings - * - * @return void - */ public function getDetailPidSetting(): void { $detailPid = (int)$this->getFieldFromFlexform('settings.detailPid', 'additional'); @@ -242,16 +187,11 @@ public function getDetailPidSetting(): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_additional.detailPid'), - $content + $content, ]; } } - /** - * Render listPid news settings - * - * @return void - */ public function getListPidSetting(): void { $listPid = (int)$this->getFieldFromFlexform('settings.listPid', 'additional'); @@ -261,29 +201,12 @@ public function getListPidSetting(): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_additional.listPid'), - $content + $content, ]; } } - /** - * Get the rendered page title including onclick menu - * - * @param int $detailPid - * @return string - * @deprecated use getRecordData() instead - */ - public function getPageRecordData($detailPid): string - { - return $this->getRecordData($detailPid, 'pages'); - } - - /** - * @param int $id - * @param string $table - * @return string - */ - public function getRecordData($id, $table = 'pages'): string + public function getRecordData(int $id, string $table = 'pages'): string { $record = BackendUtilityCore::getRecord($table, $id); @@ -322,11 +245,6 @@ public function getRecordData($id, $table = 'pages'): string return $content; } - /** - * Get order settings - * - * @return void - */ public function getOrderSettings(): void { $orderField = $this->getFieldFromFlexform('settings.orderBy'); @@ -347,16 +265,11 @@ public function getOrderSettings(): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.orderBy'), - $text + $text, ]; } } - /** - * Get order direction - * - * @return string - */ public function getOrderDirectionSetting(): string { $text = ''; @@ -369,11 +282,6 @@ public function getOrderDirectionSetting(): string return $text; } - /** - * Get topNewsFirst setting - * - * @return string - */ public function getTopNewsFirstSetting(): string { $text = ''; @@ -385,14 +293,7 @@ public function getTopNewsFirstSetting(): string return $text; } - /** - * Render category settings - * - * @param bool $showCategoryMode show the category conjunction - * - * @return void - */ - public function getCategorySettings($showCategoryMode = true): void + public function getCategorySettings(bool $showCategoryMode = true): void { $categories = GeneralUtility::intExplode(',', $this->getFieldFromFlexform('settings.categories') ?? '', true); if (count($categories) > 0) { @@ -403,7 +304,7 @@ public function getCategorySettings($showCategoryMode = true): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.categories'), - implode(', ', $categoriesOut) + implode(', ', $categoriesOut), ]; // Category mode @@ -423,7 +324,7 @@ public function getCategorySettings($showCategoryMode = true): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.categoryConjunction'), - $categoryMode + $categoryMode, ]; } @@ -431,17 +332,12 @@ public function getCategorySettings($showCategoryMode = true): void if ($includeSubcategories) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.includeSubCategories'), - '' + '', ]; } } } - /** - * Get the restriction for tags - * - * @return void - */ public function getTagRestrictionSetting() { $tags = GeneralUtility::intExplode(',', $this->getFieldFromFlexform('settings.tags', 'additional') ?? '', true); @@ -456,15 +352,10 @@ public function getTagRestrictionSetting() $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_additional.tags'), - implode(', ', $categoryTitles) + implode(', ', $categoryTitles), ]; } - /** - * Render offset & limit configuration - * - * @return void - */ public function getOffsetLimitSettings(): void { $offset = $this->getFieldFromFlexform('settings.offset', 'additional'); @@ -474,43 +365,33 @@ public function getOffsetLimitSettings(): void if ($offset) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_additional.offset'), - $offset + $offset, ]; } if ($limit) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_additional.limit'), - $limit + $limit, ]; } if ($hidePagination) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_additional.hidePagination'), - '' + '', ]; } } - /** - * Render date menu configuration - * - * @return void - */ public function getDateMenuSettings(): void { $dateMenuField = $this->getFieldFromFlexform('settings.dateField'); $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.dateField'), - $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.dateField.' . $dateMenuField) + $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.dateField.' . $dateMenuField), ]; } - /** - * Render time restriction configuration - * - * @return void - */ public function getTimeRestrictionSetting(): void { $timeRestriction = $this->getFieldFromFlexform('settings.timeRestriction'); @@ -518,7 +399,7 @@ public function getTimeRestrictionSetting(): void if (!empty($timeRestriction)) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.timeRestriction'), - htmlspecialchars($timeRestriction) + htmlspecialchars($timeRestriction), ]; } @@ -526,35 +407,23 @@ public function getTimeRestrictionSetting(): void if (!empty($timeRestrictionHigh)) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.timeRestrictionHigh'), - htmlspecialchars($timeRestrictionHigh) + htmlspecialchars($timeRestrictionHigh), ]; } } - /** - * Render top news restriction configuration - * - * @return void - */ public function getTopNewsRestrictionSetting(): void { $topNewsRestriction = (int)$this->getFieldFromFlexform('settings.topNewsRestriction'); if ($topNewsRestriction > 0) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.topNewsRestriction'), - $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.topNewsRestriction.' . $topNewsRestriction) + $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.topNewsRestriction.' . $topNewsRestriction), ]; } } - /** - * Render template layout configuration - * - * @param int $pageUid - * - * @return void - */ - public function getTemplateLayoutSettings($pageUid): void + public function getTemplateLayoutSettings(int $pageUid): void { $title = ''; $field = $this->getFieldFromFlexform('settings.templateLayout', 'template'); @@ -572,35 +441,25 @@ public function getTemplateLayoutSettings($pageUid): void if (!empty($title)) { $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_template.templateLayout'), - $this->getLanguageService()->sL($title) + $this->getLanguageService()->sL($title), ]; } } - /** - * Get information if override demand setting is disabled or not - * - * @return void - */ public function getOverrideDemandSettings(): void { - $field = $this->getFieldFromFlexform('settings.disableOverrideDemand', 'additional'); + $field = (bool)$this->getFieldFromFlexform('settings.disableOverrideDemand', 'additional'); - if ($field == 1) { + if ($field) { $this->tableData[] = [ $this->getLanguageService()->sL( self::LLPATH . 'flexforms_additional.disableOverrideDemand' ), - '' + '', ]; } } - /** - * Get the startingpoint - * - * @return void - */ public function getStartingPoint(): void { $value = $this->getFieldFromFlexform('settings.startingpoint'); @@ -629,16 +488,11 @@ public function getStartingPoint(): void $this->tableData[] = [ $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint'), - implode(', ', $pagesOut) . $recursiveLevelText + implode(', ', $pagesOut) . $recursiveLevelText, ]; } } - /** - * Get list of selected news items - * - * @return void - */ protected function getSelectedListSetting(): void { $value = $this->getFieldFromFlexform('settings.selectedList'); @@ -653,33 +507,17 @@ protected function getSelectedListSetting(): void $this->tableData[] = [ $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.selectedList'), - implode('
', $out) + implode('
', $out), ]; } } - /** - * Render an alert box - * - * @param string $text - * @return string - */ - protected function generateCallout($text): string + protected function generateCallout(string $text): string { - return '
- ' . htmlspecialchars($text) . ' -
'; + return '
' . htmlspecialchars($text) . '
'; } - /** - * Render the settings as table for Web>Page module - * System settings are displayed in mono font - * - * @param string $header - * @param int $recordUid - * @return string - */ - protected function renderSettingsAsTable($header = '', $recordUid = 0): string + protected function renderSettingsAsTable(string $header = '', int $recordUid = 0): string { $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/News/PageLayout'); @@ -691,23 +529,15 @@ protected function renderSettingsAsTable($header = '', $recordUid = 0): string 'header' => $header, 'rows' => [ 'above' => array_slice($this->tableData, 0, self::SETTINGS_IN_PREVIEW), - 'below' => array_slice($this->tableData, self::SETTINGS_IN_PREVIEW) + 'below' => array_slice($this->tableData, self::SETTINGS_IN_PREVIEW), ], - 'id' => $recordUid + 'id' => $recordUid, ]); return $view->render(); } - /** - * Get field value from flexform configuration, - * including checks if flexform configuration is available - * - * @param string $key name of the key - * @param string $sheet name of the sheet - * @return string|null if nothing found, value if found - */ - public function getFieldFromFlexform($key, $sheet = 'sDEF'): ?string + public function getFieldFromFlexform(string $key, string $sheet = 'sDEF'): ?string { $flexform = $this->flexformData; if (isset($flexform['data'])) { @@ -721,15 +551,7 @@ public function getFieldFromFlexform($key, $sheet = 'sDEF'): ?string return null; } - /** - * Build a backend edit link based on given record. - * - * @param array $row Current record row from database. - * @param int $currentPageUid current page uid - * @return string Link to open an edit window for record. - * @see \TYPO3\CMS\Backend\Utility\BackendUtilityCore::readPageAccess() - */ - protected function getEditLink($row, $currentPageUid): string + protected function getEditLink(array $row, int $currentPageUid): string { $editLink = ''; $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtilityCore::getRecord('pages', $row['uid'])); @@ -739,29 +561,9 @@ protected function getEditLink($row, $currentPageUid): string $returnUrl = $uriBuilder->buildUriFromRoute('web_layout', ['id' => $currentPageUid]); $editLink = $uriBuilder->buildUriFromRoute('web_layout', [ 'id' => $row['uid'], - 'returnUrl' => $returnUrl + 'returnUrl' => $returnUrl, ]); } - return $editLink; - } - - /** - * Return language service instance - * - * @return \TYPO3\CMS\Core\Localization\LanguageService - */ - public function getLanguageService(): \TYPO3\CMS\Core\Localization\LanguageService - { - return $GLOBALS['LANG']; - } - - /** - * Get the DocumentTemplate - * - * @return DocumentTemplate - */ - protected function getDocumentTemplate(): DocumentTemplate - { - return $GLOBALS['TBE_TEMPLATE']; + return (string)$editLink; } } diff --git a/Classes/Jobs/AbstractImportJob.php b/Classes/Jobs/AbstractImportJob.php index 03e20b5779..f8d1a91a5d 100644 --- a/Classes/Jobs/AbstractImportJob.php +++ b/Classes/Jobs/AbstractImportJob.php @@ -1,14 +1,14 @@ getFallbackType() === 'strict') { + // @extensionScannerIgnoreLine $newsRecord = $this->getNewsRecord($newsId, $language->getLanguageId()); if (!is_array($newsRecord) || empty($newsRecord)) { @@ -80,29 +81,29 @@ protected function getNewsRecord(int $newsId, int $language) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_news_domain_model_news'); if ($language === 0) { $where = [ - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)) ), - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)), ]; } else { $where = [ - $queryBuilder->expr()->orX( - $queryBuilder->expr()->andX( + $queryBuilder->expr()->or( + $queryBuilder->expr()->and( $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) ), - $queryBuilder->expr()->andX( + $queryBuilder->expr()->and( $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)) ), - $queryBuilder->expr()->andX( + $queryBuilder->expr()->and( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)) ) - ) + ), ]; } @@ -110,8 +111,7 @@ protected function getNewsRecord(int $newsId, int $language) ->select('uid', 'l10n_parent', 'sys_language_uid') ->from('tx_news_domain_model_news') ->where(...$where) - ->execute() - ->fetch(); + ->executeQuery()->fetchAssociative(); return $row ?: null; } diff --git a/Classes/Seo/NewsTitleProvider.php b/Classes/Seo/NewsTitleProvider.php index 403bf28b23..fe25f690a9 100644 --- a/Classes/Seo/NewsTitleProvider.php +++ b/Classes/Seo/NewsTitleProvider.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Seo; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ +namespace GeorgRinger\News\Seo; + use GeorgRinger\News\Domain\Model\News; use TYPO3\CMS\Core\PageTitle\AbstractPageTitleProvider; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/Seo/NewsXmlSitemapDataProvider.php b/Classes/Seo/NewsXmlSitemapDataProvider.php index 686e950a2e..5fdf70759e 100644 --- a/Classes/Seo/NewsXmlSitemapDataProvider.php +++ b/Classes/Seo/NewsXmlSitemapDataProvider.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Seo; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Seo; + use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\WorkspaceAspect; @@ -68,7 +69,8 @@ public function generateItems(): void $GLOBALS['TCA'][$table]['ctrl']['languageField'], [ -1, // All languages - $this->getLanguageId() // Current language + // @extensionScannerIgnoreLine + $this->getLanguageId(), // Current language ] ); } @@ -122,25 +124,24 @@ public function generateItems(): void // Count all items $queryBuilder->count('*'); - $this->itemCount = $queryBuilder->execute()->fetchColumn(0); + $this->itemCount = $queryBuilder->executeQuery()->fetchOne(); // Select only the right range $queryBuilder->select('*'); - $pageNumber = (int) ($this->request->getQueryParams()['page'] ?? 0); + $pageNumber = (int)($this->request->getQueryParams()['page'] ?? 0); $page = $pageNumber > 0 ? $pageNumber : 0; $queryBuilder ->setFirstResult($page * $this->numberOfItemsPerPage) ->setMaxResults($this->numberOfItemsPerPage); $rows = $queryBuilder->orderBy($sortField, $forGoogleNews ? 'DESC' : 'ASC') - ->execute() - ->fetchAll(); + ->executeQuery()->fetchAllAssociative(); foreach ($rows as $row) { $this->items[] = [ 'data' => $row, 'lastMod' => (int)$row[$lastModifiedField], - 'priority' => 0.5 + 'priority' => 0.5, ]; } } @@ -162,7 +163,7 @@ public function getItems(): array */ public function getNumberOfPages(): int { - return (int) ceil($this->itemCount / $this->numberOfItemsPerPage); + return (int)ceil($this->itemCount / $this->numberOfItemsPerPage); } /** @@ -171,6 +172,7 @@ public function getNumberOfPages(): int */ protected function defineUrl(array $data): array { + // @extensionScannerIgnoreLine $pageId = $this->config['url']['pageId'] ?? $GLOBALS['TSFE']->id; if (($this->config['url']['useCategorySinglePid'] ?? false) && $pageIdFromCategory = $this->getSinglePidFromCategory($data['data']['uid'])) { $pageId = $pageIdFromCategory; @@ -238,7 +240,7 @@ protected function getSinglePidFromCategory(int $newsId): int $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) ) ->setMaxResults(1) - ->execute()->fetch(); + ->executeQuery()->fetchAssociative(); return (int)$categoryRecord['single_pid']; } diff --git a/Classes/Service/AccessControlService.php b/Classes/Service/AccessControlService.php index fcdcedb8d9..231f4c99a8 100644 --- a/Classes/Service/AccessControlService.php +++ b/Classes/Service/AccessControlService.php @@ -1,14 +1,14 @@ expr()->eq('tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR)), $queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter('categories', \PDO::PARAM_STR)) ) - ->execute() - ->fetchColumn(0); + ->executeQuery()->fetchOne(); if ($newsRecordCategoriesCount > 0) { // take categories from localized version $newsRecordUid = $newsRecord['uid']; @@ -146,13 +145,13 @@ public static function getCategoriesForNewsRecord($newsRecord): array $queryBuilder->expr()->eq('sys_category_record_mm.fieldname', $queryBuilder->createNamedParameter('categories', \PDO::PARAM_STR)), $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsRecordUid, \PDO::PARAM_INT)) ) - ->execute(); + ->executeQuery(); $categories = []; - while ($row =$res->fetch()) { + while ($row =$res->fetchAssociative()) { $categories[] = [ 'uid' => $row['uid_local'], - 'title' => $row['title'] + 'title' => $row['title'], ]; } return $categories; diff --git a/Classes/Service/CategoryService.php b/Classes/Service/CategoryService.php index 91ef4b0b38..48698e2743 100644 --- a/Classes/Service/CategoryService.php +++ b/Classes/Service/CategoryService.php @@ -1,14 +1,14 @@ where( $queryBuilder->expr()->in('parent', $queryBuilder->createNamedParameter(array_map('intval', explode(',', $idList)), Connection::PARAM_INT_ARRAY)) ) - ->execute(); + ->executeQuery(); - while (($row = $res->fetch())) { + while ($row = $res->fetchAssociative()) { $counter++; if ($counter > 10000) { GeneralUtility::makeInstance(TimeTracker::class)->setTSlogMessage('EXT:news: one or more recursive categories where found'); @@ -119,14 +119,9 @@ private static function getChildrenCategoriesRecursive($idList, $counter = 0, $a * @param string $default default label * @param array $row category record * @return string - * @throws \UnexpectedValueException */ public static function translateCategoryRecord($default, array $row = []): string { - if (TYPO3_MODE !== 'BE') { - throw new \UnexpectedValueException('TYPO3 Mode must be BE'); - } - $overlayLanguage = (int)($GLOBALS['BE_USER']->uc['newsoverlay'] ?? 0); $title = ''; @@ -146,7 +141,7 @@ public static function translateCategoryRecord($default, array $row = []): strin $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)) ) ->setMaxResults(1) - ->execute()->fetch(); + ->executeQuery()->fetchAssociative(); if (is_array($overlayRecord) && !empty($overlayRecord)) { $title = $overlayRecord['title'] . ' (' . $row['title'] . ')'; diff --git a/Classes/Service/Import/DataProviderServiceInterface.php b/Classes/Service/Import/DataProviderServiceInterface.php index 97ae5d45df..073e048532 100644 --- a/Classes/Service/Import/DataProviderServiceInterface.php +++ b/Classes/Service/Import/DataProviderServiceInterface.php @@ -1,14 +1,14 @@ orderBy('sys_category_record_mm.sorting') ->setMaxResults(1) - ->execute()->fetch(); + ->executeQuery()->fetchAssociative(); return (int)($categoryRecord['single_pid'] ?? 0); } } diff --git a/Classes/Service/SettingsService.php b/Classes/Service/SettingsService.php index c2c3bc3592..28a6958562 100644 --- a/Classes/Service/SettingsService.php +++ b/Classes/Service/SettingsService.php @@ -1,16 +1,17 @@ slugService = GeneralUtility::makeInstance(SlugHelper::class, 'tx_news_domain_model_news', 'path_segment', $fieldConfig); } - /** - * @return int - */ public function countOfSlugUpdates(): int { /** @var QueryBuilder $queryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_news_domain_model_news'); $queryBuilder->getRestrictions()->removeAll(); - $elementCount = $queryBuilder->count('uid') + return (int)$queryBuilder->count('uid') ->from('tx_news_domain_model_news') ->where( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)), $queryBuilder->expr()->isNull('path_segment') ) ) - ->execute()->fetchColumn(0); - - return $elementCount; + ->executeQuery()->fetchOne(); } - /** - * @return array - */ public function performUpdates(): array { $databaseQueries = []; - /** @var Connection $connection */ $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_news_domain_model_news'); - /** @var QueryBuilder $queryBuilder */ $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->getRestrictions()->removeAll(); $statement = $queryBuilder->select('*') ->from('tx_news_domain_model_news') ->where( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)), $queryBuilder->expr()->isNull('path_segment') ) ) - ->execute(); - while ($record = $statement->fetch()) { + ->executeQuery(); + while ($record = $statement->fetchAssociative()) { if ((string)$record['title'] !== '') { $slug = $this->slugService->generate($record, $record['pid']); /** @var QueryBuilder $queryBuilder */ @@ -82,30 +73,30 @@ public function performUpdates(): array ) ->set('path_segment', $this->getUniqueValue($record['uid'], $record['sys_language_uid'], $slug)); $databaseQueries[] = $queryBuilder->getSQL(); - $queryBuilder->execute(); + $queryBuilder->executeStatement(); } } return $databaseQueries; } - /** - * @param int $uid - * @param string $slug - * @return string - */ protected function getUniqueValue(int $uid, int $languageId, string $slug): string { - $statement = $this->getUniqueCountStatement($uid, $languageId, $slug); - if ($statement->fetchColumn()) { - for ($counter = 1; $counter <= 100; $counter++) { + $queryBuilder = $this->getUniqueCountStatement($uid, $languageId, $slug); + // For as long as records with the test-value existing, try again (with incremented numbers appended) + $statement = $queryBuilder->prepare(); + $result = $statement->executeQuery(); + if ($result->fetchOne()) { + for ($counter = 0; $counter <= 100; $counter++) { + $result->free(); $newSlug = $slug . '-' . $counter; $statement->bindValue(1, $newSlug); - $statement->execute(); - if (!$statement->fetchColumn()) { + $result = $statement->executeQuery(); + if (!$result->fetchOne()) { break; } } + $result->free(); } return $newSlug ?? $slug; @@ -115,13 +106,10 @@ protected function getUniqueValue(int $uid, int $languageId, string $slug): stri * @param int $uid * @param int $languageId * @param string $slug - * @return \Doctrine\DBAL\Driver\Statement|int */ protected function getUniqueCountStatement(int $uid, int $languageId, string $slug) { - /** @var QueryBuilder $queryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_news_domain_model_news'); - /** @var DeletedRestriction $deleteRestriction */ $deleteRestriction = GeneralUtility::makeInstance(DeletedRestriction::class); $queryBuilder->getRestrictions()->removeAll()->add($deleteRestriction); @@ -138,25 +126,22 @@ protected function getUniqueCountStatement(int $uid, int $languageId, string $sl $queryBuilder->createPositionalParameter($languageId, \PDO::PARAM_INT) ), $queryBuilder->expr()->neq('uid', $queryBuilder->createPositionalParameter($uid, \PDO::PARAM_INT)) - )->execute(); + ); } /** * Count valid entries from EXT:realurl table tx_realurl_uniqalias which can be migrated * Checks also for existance of third party extension table 'tx_realurl_uniqalias' * EXT:realurl requires not to be installed - * - * @return int */ public function countOfRealurlAliasMigrations(): int { $elementCount = 0; // Check if table 'tx_realurl_uniqalias' exists - /** @var QueryBuilder $queryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_realurl_uniqalias'); $schemaManager = $queryBuilder->getConnection()->getSchemaManager(); - if ($schemaManager->tablesExist(['tx_realurl_uniqalias']) === true) { + if ($schemaManager && $schemaManager->tablesExist(['tx_realurl_uniqalias']) === true) { // Count valid aliases for news $queryBuilder->getRestrictions()->removeAll(); $elementCount = $queryBuilder->selectLiteral('COUNT(DISTINCT tx_news_domain_model_news.uid)') @@ -171,8 +156,8 @@ public function countOfRealurlAliasMigrations(): int ) ) ->where( - $queryBuilder->expr()->andX( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->and( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_news_domain_model_news.path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR) @@ -187,7 +172,7 @@ public function countOfRealurlAliasMigrations(): int 'tx_realurl_uniqalias.tablename', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) ), - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_realurl_uniqalias.expire', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) @@ -199,26 +184,23 @@ public function countOfRealurlAliasMigrations(): int ) ) ) - ->execute()->fetchColumn(0); + ->executeQuery()->fetchOne(); } return $elementCount; } /** * Perform migration of EXT:realurl unique alias into empty news slugs - * - * @return array */ public function performRealurlAliasMigration(): array { $databaseQueries = []; // Check if table 'tx_realurl_uniqalias' exists - /** @var QueryBuilder $queryBuilderForRealurl */ $queryBuilderForRealurl = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_realurl_uniqalias'); $schemaManager = $queryBuilderForRealurl->getConnection()->getSchemaManager(); - if ($schemaManager->tablesExist(['tx_realurl_uniqalias']) === true) { + if ($schemaManager && $schemaManager->tablesExist(['tx_realurl_uniqalias']) === true) { /** @var Connection $connection */ $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable('tx_news_domain_model_news'); @@ -234,12 +216,12 @@ public function performRealurlAliasMigration(): array 'tx_news_domain_model_news', 'tx_realurl_uniqalias', 'tx_realurl_uniqalias', - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_news_domain_model_news.uid', $queryBuilder->quoteIdentifier('tx_realurl_uniqalias.value_id') ), - $queryBuilder->expr()->andX( + $queryBuilder->expr()->and( $queryBuilder->expr()->eq( 'tx_news_domain_model_news.l10n_parent', $queryBuilder->quoteIdentifier('tx_realurl_uniqalias.value_id') @@ -252,8 +234,8 @@ public function performRealurlAliasMigration(): array ) ) ->where( - $queryBuilder->expr()->andX( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->and( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_news_domain_model_news.path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR) @@ -268,7 +250,7 @@ public function performRealurlAliasMigration(): array 'tx_realurl_uniqalias.tablename', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) ), - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_realurl_uniqalias.expire', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) @@ -280,10 +262,10 @@ public function performRealurlAliasMigration(): array ) ) ) - ->execute(); + ->executeQuery(); // Update entries - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $slug = $this->slugService->sanitize((string)$record['value_alias']); $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->update('tx_news_domain_model_news') @@ -295,7 +277,7 @@ public function performRealurlAliasMigration(): array ) ->set('path_segment', $this->getUniqueValue($record['uid'], $record['sys_language_uid'], $slug)); $databaseQueries[] = $queryBuilder->getSQL(); - $queryBuilder->execute(); + $queryBuilder->executeStatement(); } } diff --git a/Classes/TreeProvider/DatabaseTreeDataProvider.php b/Classes/TreeProvider/DatabaseTreeDataProvider.php index 44f2e13381..6823be9407 100644 --- a/Classes/TreeProvider/DatabaseTreeDataProvider.php +++ b/Classes/TreeProvider/DatabaseTreeDataProvider.php @@ -1,138 +1,17 @@ getId() == 0) { - $node->setSelected(false); - $node->setExpanded(true); - $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title'])); - } else { - $row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', false); - - if ($this->getLabelField() !== '') { - $label = CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row); - $node->setLabel($label); - } else { - $node->setLabel($basicNode->getId()); - } - $node->setSelected(GeneralUtility::inList($this->getSelectedList(), $basicNode->getId())); - $node->setExpanded($this->isExpanded($basicNode)); - $node->setLabel($node->getLabel()); - } - - $node->setId($basicNode->getId()); - - // Break to force single category activation - if ($parent != null && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) { - return null; - } - $node->setSelectable(!GeneralUtility::inList( - $this->getNonSelectableLevelList(), - $level - ) && !in_array($basicNode->getId(), $this->getItemUnselectableList())); - if (!empty($this->nodeSortValues)) { - $node->setSortValue($this->nodeSortValues[$basicNode->getId()]); - } - $node->setIcon($iconFactory->getIconForRecord($this->tableName, $row, Icon::SIZE_SMALL)); - $node->setParentNode($parent); - if ($basicNode->hasChildNodes()) { - $node->setHasChildren(true); - $childNodes = GeneralUtility::makeInstance(SortedTreeNodeCollection::class); - $foundSomeChild = false; - foreach ($basicNode->getChildNodes() as $child) { - // Change in custom TreeDataProvider by adding the if clause - if ($restriction || $this->isCategoryAllowed($child)) { - $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, true); - - if (!is_null($returnedChild)) { - $foundSomeChild = true; - $childNodes->append($returnedChild); - } else { - $node->setParentNode(null); - $node->setHasChildren(false); - } - } - // Change in custom TreeDataProvider end - } - - if ($foundSomeChild) { - $node->setChildNodes($childNodes); - } - } - return $node; - } - - /** - * Check if given category is allowed by the access rights - * - * @param \TYPO3\CMS\Backend\Tree\TreeNode $child - * @return bool - */ - protected function isCategoryAllowed($child): bool - { - $mounts = $GLOBALS['BE_USER']->getCategoryMountPoints(); - if (empty($mounts)) { - return true; - } - - return in_array($child->getId(), $mounts); - } - - /** - * By setting "tx_news.singleCategoryAcl = 1" in UserTsConfig - * every category needs to be activated, no recursive enabling - * - * @return bool - */ - protected function isSingleCategoryAclActivated(): bool - { - $userTsConfig = $GLOBALS['BE_USER']->getTSConfig(); - if (is_array($userTsConfig['tx_news.']) - && $userTsConfig['tx_news.']['singleCategoryAcl'] === '1' - ) { - return true; - } - - return false; - } } diff --git a/Classes/Updates/NewsSlugUpdater.php b/Classes/Updates/NewsSlugUpdater.php index d125b02520..40ebc9496f 100644 --- a/Classes/Updates/NewsSlugUpdater.php +++ b/Classes/Updates/NewsSlugUpdater.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Updates; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Updates; + use GeorgRinger\News\Service\SlugService; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; @@ -50,7 +51,7 @@ public function updateNecessary(): bool public function getPrerequisites(): array { return [ - DatabaseUpdatedPrerequisite::class + DatabaseUpdatedPrerequisite::class, ]; } diff --git a/Classes/Updates/PluginPermissionUpdater.php b/Classes/Updates/PluginPermissionUpdater.php new file mode 100644 index 0000000000..e2a1b54b94 --- /dev/null +++ b/Classes/Updates/PluginPermissionUpdater.php @@ -0,0 +1,124 @@ +getMigrationRecords()); + return $description; + } + + public function getPrerequisites(): array + { + return [ + DatabaseUpdatedPrerequisite::class, + ]; + } + + public function updateNecessary(): bool + { + return $this->checkIfWizardIsRequired(); + } + + public function executeUpdate(): bool + { + return $this->performMigration(); + } + + public function checkIfWizardIsRequired(): bool + { + return count($this->getMigrationRecords()) > 0; + } + + public function performMigration(): bool + { + $records = $this->getMigrationRecords(); + + foreach ($records as $record) { + $this->updateRow($record); + } + + return true; + } + + protected function getMigrationRecords(): array + { + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable('be_groups'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + + return $queryBuilder + ->select('uid', 'explicit_allowdeny') + ->from('be_groups') + ->where( + $queryBuilder->expr()->like( + 'explicit_allowdeny', + $queryBuilder->createNamedParameter('%' . $queryBuilder->escapeLikeWildcards('tt_content:list_type:news_pi1') . '%') + ) + ) + ->executeQuery() + ->fetchAllAssociative(); + } + + protected function updateRow(array $row): void + { + $default = 'tt_content:CType:news_pi1,tt_content:CType:news_newsliststicky,tt_content:CType:news_newsdetail,tt_content:CType:news_newsdatemenu,tt_content:CType:news_newssearchform,tt_content:CType:news_newssearchresult,tt_content:CType:news_newsselectedlist,tt_content:CType:news_categorylist,tt_content:CType:news_taglist'; + + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() >= 12) { + $searchReplace = [ + 'tt_content:list_type:news_pi1:ALLOW' => $default, + 'tt_content:list_type:news_pi1:DENY' => '', + 'tt_content:list_type:news_pi1' => $default, + ]; + } else { + $default .= ','; + $default = str_replace(',', ':ALLOW,', $default); + $searchReplace = [ + 'tt_content:list_type:news_pi1:ALLOW' => $default, + 'tt_content:list_type:news_pi1:DENY' => str_replace($default, 'ALLOW', 'DENY'), + ]; + } + + $newList = str_replace(array_keys($searchReplace), array_values($searchReplace), $row['explicit_allowdeny']); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_groups'); + $queryBuilder->update('be_groups') + ->set('explicit_allowdeny', $newList) + ->where( + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter($row['uid'], Connection::PARAM_INT) + ) + ) + ->executeStatement(); + } +} diff --git a/Classes/Updates/PluginUpdater.php b/Classes/Updates/PluginUpdater.php new file mode 100644 index 0000000000..503397f16f --- /dev/null +++ b/Classes/Updates/PluginUpdater.php @@ -0,0 +1,244 @@ + 'News->list;News->detail', + 'targetListType' => 'news_pi1', + ], + [ + 'switchableControllerActions' => 'News->list', + 'targetListType' => 'news_newsliststicky', + ], + [ + 'switchableControllerActions' => 'News->selectedList', + 'targetListType' => 'news_newsselectedlist', + ], + [ + 'switchableControllerActions' => 'News->detail', + 'targetListType' => 'news_newsdetail', + ], + [ + 'switchableControllerActions' => 'News->dateMenu', + 'targetListType' => 'news_newsdatemenu', + ], + [ + 'switchableControllerActions' => 'News->searchForm', + 'targetListType' => 'news_newssearchform', + ], + [ + 'switchableControllerActions' => 'News->searchResult', + 'targetListType' => 'news_newssearchresult', + ], + [ + 'switchableControllerActions' => 'Category->list', + 'targetListType' => 'news_categorylist', + ], + [ + 'switchableControllerActions' => 'Tag->list', + 'targetListType' => 'news_taglist', + ], + ]; + + /** @var FlexFormService */ + protected $flexFormService; + + public function __construct() + { + $this->flexFormService = GeneralUtility::makeInstance(FlexFormService::class); + } + + public function getIdentifier(): string + { + return 'txNewsPluginUpdater'; + } + + public function getTitle(): string + { + return 'EXT:news: Migrate plugins'; + } + + public function getDescription(): string + { + $description = 'The old plugin using switchableControllerActions has been split into separate plugins. '; + $description .= 'This update wizard migrates all existing plugin settings and changes the plugin'; + $description .= 'to use the new plugins available. Count of plugins: ' . count($this->getMigrationRecords()); + return $description; + } + + public function getPrerequisites(): array + { + return [ + DatabaseUpdatedPrerequisite::class, + ]; + } + + public function updateNecessary(): bool + { + return $this->checkIfWizardIsRequired(); + } + + public function executeUpdate(): bool + { + return $this->performMigration(); + } + + public function checkIfWizardIsRequired(): bool + { + return count($this->getMigrationRecords()) > 0; + } + + public function performMigration(): bool + { + $records = $this->getMigrationRecords(); + + foreach ($records as $record) { + $flexFormData = GeneralUtility::xml2array($record['pi_flexform']); + $flexForm = $this->flexFormService->convertFlexFormContentToArray($record['pi_flexform']); + $targetListType = $this->getTargetListType($flexForm['switchableControllerActions']); + $allowedSettings = $this->getAllowedSettingsFromFlexForm($targetListType); + + // Remove flexform data which do not exist in flexform of new plugin + foreach ($flexFormData['data'] as $sheetKey => $sheetData) { + foreach ($sheetData['lDEF'] as $settingName => $setting) { + if (!in_array($settingName, $allowedSettings, true)) { + unset($flexFormData['data'][$sheetKey]['lDEF'][$settingName]); + } + } + + // Remove empty sheets + if (!count($flexFormData['data'][$sheetKey]['lDEF']) > 0) { + unset($flexFormData['data'][$sheetKey]); + } + } + + if (count($flexFormData['data']) > 0) { + $newFlexform = $this->array2xml($flexFormData); + } else { + $newFlexform = ''; + } + + $this->updateContentElement($record['uid'], $targetListType, $newFlexform); + } + + return true; + } + + protected function getMigrationRecords(): array + { + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable('tt_content'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + + return $queryBuilder + ->select('uid', 'list_type', 'pi_flexform') + ->from('tt_content') + ->where( + $queryBuilder->expr()->eq( + 'list_type', + $queryBuilder->createNamedParameter('news_pi1') + ) + ) + ->executeQuery() + ->fetchAllAssociative(); + } + + protected function getTargetListType(string $switchableControllerActions): string + { + foreach (self::MIGRATION_SETTINGS as $setting) { + if ($setting['switchableControllerActions'] === $switchableControllerActions + ) { + return $setting['targetListType']; + } + } + + return ''; + } + + protected function getAllowedSettingsFromFlexForm(string $listType): array + { + $flexFormFile = $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['*,' . $listType]; + $flexFormContent = file_get_contents(GeneralUtility::getFileAbsFileName(substr(trim($flexFormFile), 5))); + $flexFormData = GeneralUtility::xml2array($flexFormContent); + + // Iterate each sheet and extract all settings + $settings = []; + foreach ($flexFormData['sheets'] as $sheet) { + foreach ($sheet['ROOT']['el'] as $setting => $tceForms) { + $settings[] = $setting; + } + } + + return $settings; + } + + /** + * Updates list_type and pi_flexform of the given content element UID + * + * @param int $uid + * @param string $newCtype + * @param string $flexform + */ + protected function updateContentElement(int $uid, string $newCtype, string $flexform): void + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); + $queryBuilder->update('tt_content') + ->set('CType', $newCtype) + ->set('list_type', '') + ->set('pi_flexform', $flexform) + ->where( + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT) + ) + ) + ->executeStatement(); + } + + /** + * Transforms the given array to FlexForm XML + * + * @param array $input + * @return string + */ + protected function array2xml(array $input = []): string + { + $options = [ + 'parentTagMap' => [ + 'data' => 'sheet', + 'sheet' => 'language', + 'language' => 'field', + 'el' => 'field', + 'field' => 'value', + 'field:el' => 'el', + 'el:_IS_NUM' => 'section', + 'section' => 'itemType', + ], + 'disableTypeAttrib' => 2, + ]; + $spaceInd = 4; + $output = GeneralUtility::array2xml($input, '', 0, 'T3FlexForms', $spaceInd, $options); + $output = '' . LF . $output; + return $output; + } +} diff --git a/Classes/Updates/PopulateCategorySlugs.php b/Classes/Updates/PopulateCategorySlugs.php index 6f52129864..99908d260a 100644 --- a/Classes/Updates/PopulateCategorySlugs.php +++ b/Classes/Updates/PopulateCategorySlugs.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Updates; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Updates; + use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory; @@ -72,7 +73,7 @@ public function updateNecessary(): bool public function getPrerequisites(): array { return [ - DatabaseUpdatedPrerequisite::class + DatabaseUpdatedPrerequisite::class, ]; } @@ -89,8 +90,6 @@ public function executeUpdate(): bool /** * Fills the database table with slugs based on the page title and its configuration. - * - * @return void */ protected function populateSlugs(): void { @@ -101,7 +100,7 @@ protected function populateSlugs(): void ->select('*') ->from($this->table) ->where( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq($this->fieldName, $queryBuilder->createNamedParameter('')), $queryBuilder->expr()->isNull($this->fieldName) ) @@ -110,7 +109,7 @@ protected function populateSlugs(): void ->addOrderBy('t3ver_wsid', 'asc') ->addOrderBy('pid', 'asc') ->addOrderBy('sorting', 'asc') - ->execute(); + ->executeQuery(); // Check for existing slugs from realurl $suggestedSlugs = []; @@ -121,7 +120,7 @@ protected function populateSlugs(): void $hasToBeUniqueInPid = in_array('uniqueInPid', $evalInfo, true); $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, $this->table, $this->fieldName, $fieldConfig); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $recordId = (int)$record['uid']; $pid = (int)$record['pid']; $languageId = (int)$record['sys_language_uid']; @@ -137,7 +136,7 @@ protected function populateSlugs(): void ->from($this->table) ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], \PDO::PARAM_INT)) - )->execute()->fetch(); + )->executeQuery()->fetchAssociative(); $pid = (int)$liveVersion['pid']; } $slug = $slugHelper->generate($record, $pid); @@ -162,9 +161,6 @@ protected function populateSlugs(): void /** * Check if there are record within database table with an empty "slug" field. - * - * @return bool - * @throws \InvalidArgumentException */ protected function checkIfWizardIsRequired(): bool { @@ -176,13 +172,12 @@ protected function checkIfWizardIsRequired(): bool ->count('uid') ->from($this->table) ->where( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq($this->fieldName, $queryBuilder->createNamedParameter('')), $queryBuilder->expr()->isNull($this->fieldName) ) ) - ->execute() - ->fetchColumn(); + ->executeQuery()->fetchOne(); return $numberOfEntries > 0; } } diff --git a/Classes/Updates/PopulateTagSlugs.php b/Classes/Updates/PopulateTagSlugs.php index a0881fdd9a..732368d69c 100644 --- a/Classes/Updates/PopulateTagSlugs.php +++ b/Classes/Updates/PopulateTagSlugs.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Updates; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Updates; + use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory; @@ -72,7 +73,7 @@ public function updateNecessary(): bool public function getPrerequisites(): array { return [ - DatabaseUpdatedPrerequisite::class + DatabaseUpdatedPrerequisite::class, ]; } @@ -89,8 +90,6 @@ public function executeUpdate(): bool /** * Fills the database table with slugs based on the page title and its configuration. - * - * @return void */ protected function populateSlugs(): void { @@ -101,7 +100,7 @@ protected function populateSlugs(): void ->select('*') ->from($this->table) ->where( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq($this->fieldName, $queryBuilder->createNamedParameter('')), $queryBuilder->expr()->isNull($this->fieldName) ) @@ -110,7 +109,7 @@ protected function populateSlugs(): void ->addOrderBy('t3ver_wsid', 'asc') ->addOrderBy('pid', 'asc') ->addOrderBy('sorting', 'asc') - ->execute(); + ->executeQuery(); // Check for existing slugs from realurl $suggestedSlugs = []; @@ -121,7 +120,7 @@ protected function populateSlugs(): void $hasToBeUniqueInPid = in_array('uniqueInPid', $evalInfo, true); $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, $this->table, $this->fieldName, $fieldConfig); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $recordId = (int)$record['uid']; $pid = (int)$record['pid']; $languageId = (int)$record['sys_language_uid']; @@ -137,7 +136,7 @@ protected function populateSlugs(): void ->from($this->table) ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], \PDO::PARAM_INT)) - )->execute()->fetch(); + )->executeQuery()->fetchAssociative(); $pid = (int)$liveVersion['pid']; } $slug = $slugHelper->generate($record, $pid); @@ -176,13 +175,12 @@ protected function checkIfWizardIsRequired(): bool ->count('uid') ->from($this->table) ->where( - $queryBuilder->expr()->orX( + $queryBuilder->expr()->or( $queryBuilder->expr()->eq($this->fieldName, $queryBuilder->createNamedParameter('')), $queryBuilder->expr()->isNull($this->fieldName) ) ) - ->execute() - ->fetchColumn(); + ->executeQuery()->fetchOne(); return $numberOfEntries > 0; } } diff --git a/Classes/Updates/RealurlAliasNewsSlugUpdater.php b/Classes/Updates/RealurlAliasNewsSlugUpdater.php index 602bc0fe84..c10fcd7fcb 100644 --- a/Classes/Updates/RealurlAliasNewsSlugUpdater.php +++ b/Classes/Updates/RealurlAliasNewsSlugUpdater.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * This file is part of the "news" Extension for TYPO3 CMS. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + namespace GeorgRinger\News\Updates; /* @@ -72,7 +79,7 @@ public function updateNecessary(): bool public function getPrerequisites(): array { return [ - DatabaseUpdatedPrerequisite::class + DatabaseUpdatedPrerequisite::class, ]; } diff --git a/Classes/Updates/RelatedLinkIntegerDefault.php b/Classes/Updates/RelatedLinkIntegerDefault.php index 68f7d91bc8..a6c24e8870 100644 --- a/Classes/Updates/RelatedLinkIntegerDefault.php +++ b/Classes/Updates/RelatedLinkIntegerDefault.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Updates; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Updates; + use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; @@ -61,19 +62,18 @@ public function executeUpdate(): bool Connection::PARAM_INT ) ->where($query->expr()->isNull(self::FIELD_RELATED_LINKS)) - ->execute(); + ->executeStatement(); return true; } public function updateNecessary(): bool { $query = self::getQueryBuilderForNews(); - return (bool) $query + return (bool)$query ->count(self::FIELD_UID) ->from(self::TABLE_NEWS) ->where($query->expr()->isNull(self::FIELD_RELATED_LINKS)) - ->execute() - ->fetchColumn(0); + ->executeQuery()->fetchOne(); } public function getPrerequisites(): array diff --git a/Classes/Updates/TitleFieldDefault.php b/Classes/Updates/TitleFieldDefault.php index fc074b1edc..9f7c0c602d 100644 --- a/Classes/Updates/TitleFieldDefault.php +++ b/Classes/Updates/TitleFieldDefault.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\Updates; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\Updates; + use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; @@ -61,19 +62,18 @@ public function executeUpdate(): bool Connection::PARAM_INT ) ->where($query->expr()->isNull(self::FIELD_RELATED_LINKS)) - ->execute(); + ->executeStatement(); return true; } public function updateNecessary(): bool { $query = self::getQueryBuilderForNews(); - return (bool) $query + return (bool)$query ->count(self::FIELD_UID) ->from(self::TABLE_NEWS) ->where($query->expr()->isNull(self::FIELD_RELATED_LINKS)) - ->execute() - ->fetchColumn(0); + ->executeQuery()->fetchOne(); } public function getPrerequisites(): array diff --git a/Classes/Utility/Cache.php b/Classes/Utility/Cache.php index 0559436e2a..9b6c4bd15f 100644 --- a/Classes/Utility/Cache.php +++ b/Classes/Utility/Cache.php @@ -1,5 +1,12 @@ $token[1], 'modifiers' => $mod, 'doc' => $doc, - 'start' => $token[2] + 'start' => $token[2], ]; break; case T_FUNCTION: @@ -113,7 +114,7 @@ public function parse($file): void $classes[$clsc - 1]['functions'][$token[1]] = [ 'modifiers' => $mod, 'doc' => $doc, - 'start' => $token[2] + 'start' => $token[2], ]; } break; diff --git a/Classes/Utility/ConstraintHelper.php b/Classes/Utility/ConstraintHelper.php index 1e2086f20a..364c61a80f 100644 --- a/Classes/Utility/ConstraintHelper.php +++ b/Classes/Utility/ConstraintHelper.php @@ -1,13 +1,14 @@ $className, 'title' => $title, - 'description' => $description + 'description' => $description, ]; } /** * Get all registered import jobs * - * @static * @return array */ public static function getRegisteredJobs(): array diff --git a/Classes/Utility/Page.php b/Classes/Utility/Page.php index 17b5736b89..5b06cbb334 100644 --- a/Classes/Utility/Page.php +++ b/Classes/Utility/Page.php @@ -1,20 +1,22 @@ = 0) { + // @extensionScannerIgnoreLine $pids = $queryGenerator->getTreeList($startPid, $recursive); if (strlen($pids) > 0) { $recursiveStoragePids .= ',' . $pids; } } } - return GeneralUtility::uniqueList($recursiveStoragePids); + return StringUtility::uniqueList($recursiveStoragePids); } /** @@ -57,8 +60,6 @@ public static function extendPidListByChildren($pidList = '', $recursive = 0): s * @param string $properties comma separated list of properties * @param mixed $object object or array to get the properties * @param string $prefix optional prefix - * - * @return void */ public static function setRegisterProperties($properties, $object, $prefix = 'news'): void { @@ -98,13 +99,10 @@ public static function setRegisterProperties($properties, $object, $prefix = 'ne * @param int $treeLevel count of levels * @return PageTreeView * @throws \Exception + * @deprecated not in use */ public static function pageTree($pageUid, $treeLevel): PageTreeView { - if (TYPO3_MODE !== 'BE') { - throw new \Exception('Page::pageTree does only work in the backend!'); - } - $pageUid = (int)$pageUid; if ($pageUid === 0 && !self::getBackendUser()->isAdmin()) { $mounts = self::getBackendUser()->returnWebmounts(); @@ -123,7 +121,7 @@ public static function pageTree($pageUid, $treeLevel): PageTreeView // Creating top icon; the current page $tree->tree[] = [ 'row' => $treeStartingRecord, - 'HTML' => is_array($treeStartingRecord) ? $iconFactory->getIconForRecord('pages', $treeStartingRecord, Icon::SIZE_SMALL)->render() : '' + 'HTML' => is_array($treeStartingRecord) ? $iconFactory->getIconForRecord('pages', $treeStartingRecord, Icon::SIZE_SMALL)->render() : '', ]; $tree->getTree($pageUid, $treeLevel, ''); diff --git a/Classes/Utility/TemplateLayout.php b/Classes/Utility/TemplateLayout.php index cab232f890..f3ba070317 100644 --- a/Classes/Utility/TemplateLayout.php +++ b/Classes/Utility/TemplateLayout.php @@ -1,13 +1,14 @@ expr()->eq('sys_category.uid', $queryBuilder->quoteIdentifier('sys_category_record_mm.uid_local')) ) ->where( - $queryBuilder->expr()->andX( + $queryBuilder->expr()->and( $queryBuilder->expr()->eq( 'sys_category.uid', $queryBuilder->createNamedParameter($categoryUid, \PDO::PARAM_INT) @@ -93,8 +93,7 @@ public static function renderStatic( ) ) ) - ->execute() - ->fetchColumn(0); + ->executeQuery()->fetchOne(); return $count; } diff --git a/Classes/ViewHelpers/Check/PageAvailableInLanguageViewHelper.php b/Classes/ViewHelpers/Check/PageAvailableInLanguageViewHelper.php index 63d4cf442e..32365be812 100644 --- a/Classes/ViewHelpers/Check/PageAvailableInLanguageViewHelper.php +++ b/Classes/ViewHelpers/Check/PageAvailableInLanguageViewHelper.php @@ -1,14 +1,14 @@ arguments)) { - return $this->renderThenChild(); - } - return $this->renderElseChild(); - } } diff --git a/Classes/ViewHelpers/Format/NothingViewHelper.php b/Classes/ViewHelpers/Format/NothingViewHelper.php index 256ffc1a72..a2a5b36181 100644 --- a/Classes/ViewHelpers/Format/NothingViewHelper.php +++ b/Classes/ViewHelpers/Format/NothingViewHelper.php @@ -1,15 +1,16 @@ - * - * - * - * This will include the file provided by {settings} in the header - * - */ -class IncludeFileViewHelper extends AbstractViewHelper implements ViewHelperInterface -{ - use CompileWithRenderStatic; - - public function initializeArguments() - { - $this->registerArgument('path', 'string', 'Path to the CSS/JS file which should be included', true); - $this->registerArgument('compress', 'bool', 'Define if file should be compressed', false, false); - $this->registerArgument('footer', 'bool', 'Define if JS file should be loaded in the footer', false, false); - } - - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return void - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ) { - $path = $arguments['path']; - $compress = (bool)$arguments['compress']; - $footer = (bool)$arguments['footer']; - - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - if (TYPO3_MODE === 'FE') { - $sanitizer = GeneralUtility::makeInstance(FilePathSanitizer::class); - try { - $path = $sanitizer->sanitize($path); - // JS - if (strtolower(substr($path, -3)) === '.js') { - if ($footer) { - $pageRenderer->addJsFooterFile($path, null, $compress, false, '', true); - } else { - $pageRenderer->addJsFile($path, null, $compress, false, '', true); - } - - // CSS - } elseif (strtolower(substr($path, -4)) === '.css') { - $pageRenderer->addCssFile($path, 'stylesheet', 'all', '', $compress, false, '', true); - } - } catch (\Exception $e) { - // do nothing (todo handle properly?) - } - } else { - // JS - if (strtolower(substr($path, -3)) === '.js') { - $pageRenderer->addJsFile($path, null, $compress, false, '', true); - - // CSS - } elseif (strtolower(substr($path, -4)) === '.css') { - $pageRenderer->addCssFile($path, 'stylesheet', 'all', '', $compress, false, '', true); - } - } - } -} diff --git a/Classes/ViewHelpers/Iterator/ChunkViewHelper.php b/Classes/ViewHelpers/Iterator/ChunkViewHelper.php index 8a0acb569b..1940ff67fe 100644 --- a/Classes/ViewHelpers/Iterator/ChunkViewHelper.php +++ b/Classes/ViewHelpers/Iterator/ChunkViewHelper.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\ViewHelpers\Iterator; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ +namespace GeorgRinger\News\ViewHelpers\Iterator; + use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -75,12 +75,12 @@ public static function renderStatic( $preserveKeys ); $output = []; - if (0 >= $count) { + if ($count <= 0) { return $output; } if ($fixed) { $subjectSize = count($subject); - if (0 < $subjectSize) { + if ($subjectSize > 0) { $chunkSize = (int)ceil($subjectSize / $count); $output = array_chunk($subject, $chunkSize, $preserveKeys); @@ -140,7 +140,7 @@ protected static function renderChildrenWithVariableOrReturnInputStatic( RenderingContextInterface $renderingContext, \Closure $renderChildrenClosure ) { - if (true === empty($as)) { + if (empty($as) === true) { return $variable; } $variables = [$as => $variable]; @@ -202,7 +202,7 @@ private static function restoreVariables(array $variables, array $backups, $temp { foreach ($variables as $variableName => $variableValue) { $templateVariableContainer->remove($variableName); - if (true === isset($backups[$variableName])) { + if (isset($backups[$variableName]) === true) { $templateVariableContainer->add($variableName, $variableValue); } } diff --git a/Classes/ViewHelpers/LinkViewHelper.php b/Classes/ViewHelpers/LinkViewHelper.php index 41b8161d39..64d7abff33 100644 --- a/Classes/ViewHelpers/LinkViewHelper.php +++ b/Classes/ViewHelpers/LinkViewHelper.php @@ -1,17 +1,18 @@ init(); + $this->initializeContentObjectRenderer(); $linkedContent = $this->renderChildren(); if ($newsItem === null) { @@ -131,11 +130,11 @@ public function render(): ?string case 1: $configuration['parameter'] = $newsItem->getInternalurl(); break; - // external news + // external news case 2: $configuration['parameter'] = $newsItem->getExternalurl(); break; - // normal news record + // normal news record default: $configuration = $this->getLinkToNewsItem($newsItem, $tsSettings, $configuration); } @@ -213,6 +212,7 @@ protected function getLinkToNewsItem( } if (!$detailPid && isset($GLOBALS['TSFE'])) { + // @extensionScannerIgnoreLine $detailPid = $GLOBALS['TSFE']->id; } $configuration['parameter'] = $detailPid; @@ -316,12 +316,7 @@ protected function getDetailPidFromFlexform($settings, $newsItem): int return isset($settings['detailPid']) ? (int)$settings['detailPid'] : 0; } - /** - * Initialize properties - * - * @return void - */ - protected function init(): void + protected function initializeContentObjectRenderer(): void { $this->cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); } diff --git a/Classes/ViewHelpers/MetaTagViewHelper.php b/Classes/ViewHelpers/MetaTagViewHelper.php index c85f95638a..7724826485 100644 --- a/Classes/ViewHelpers/MetaTagViewHelper.php +++ b/Classes/ViewHelpers/MetaTagViewHelper.php @@ -1,13 +1,14 @@ [ 'overwriteDemand' => [ - 'categories' => $categoryList - ] - ] + 'categories' => $categoryList, + ], + ], ]; ArrayUtility::mergeRecursiveWithOverrule($allArguments, $categoryArray); } return $allArguments; } + + private static function rmFromList($element, $list) + { + $items = explode(',', $list); + foreach ($items as $k => $v) { + if ($v == $element) { + unset($items[$k]); + } + } + return implode(',', $items); + } } diff --git a/Classes/ViewHelpers/MultiCategoryLink/IsCategoryActiveViewHelper.php b/Classes/ViewHelpers/MultiCategoryLink/IsCategoryActiveViewHelper.php index 05d095b4a8..35eb576054 100644 --- a/Classes/ViewHelpers/MultiCategoryLink/IsCategoryActiveViewHelper.php +++ b/Classes/ViewHelpers/MultiCategoryLink/IsCategoryActiveViewHelper.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace GeorgRinger\News\ViewHelpers\MultiCategoryLink; - -/** +/* * This file is part of the "news" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ + +namespace GeorgRinger\News\ViewHelpers\MultiCategoryLink; + use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface; diff --git a/Classes/ViewHelpers/PaginateBodytextViewHelper.php b/Classes/ViewHelpers/PaginateBodytextViewHelper.php index f8be693971..3590b6c25e 100644 --- a/Classes/ViewHelpers/PaginateBodytextViewHelper.php +++ b/Classes/ViewHelpers/PaginateBodytextViewHelper.php @@ -1,14 +1,16 @@ $pages, 'numberOfPages' => $numberOfPages, - 'current' => $currentPage + 'current' => $currentPage, ]; if ($currentPage < $numberOfPages) { diff --git a/Classes/ViewHelpers/RemoveMediaTagsViewHelper.php b/Classes/ViewHelpers/RemoveMediaTagsViewHelper.php index a08e01a960..80d83505dc 100644 --- a/Classes/ViewHelpers/RemoveMediaTagsViewHelper.php +++ b/Classes/ViewHelpers/RemoveMediaTagsViewHelper.php @@ -1,13 +1,14 @@ null, 'height' => null, - 'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image) + 'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image), ]; $processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions); @@ -91,7 +92,7 @@ private function renderImage(\TYPO3\CMS\Core\Resource\FileInterface $image): str $imageAttributes = [ 'src' => $imageUri, 'alt' => $alt ?: ($title ?: ''), - 'title' => $title + 'title' => $title, ]; if (!empty($this->imgClass)) { @@ -141,7 +142,7 @@ private function renderMedia($content, array $files): string } $media = $file->getOriginalResource(); - $fileRenderer = RendererRegistry::getInstance()->getRenderer($media); + $fileRenderer = GeneralUtility::makeInstance(RendererRegistry::class)->getRenderer($media); // if a renderer is configured for the file type use this renderer if ($fileRenderer !== null) { diff --git a/Classes/ViewHelpers/SearchFormViewHelper.php b/Classes/ViewHelpers/SearchFormViewHelper.php index 4f76930801..b418572430 100644 --- a/Classes/ViewHelpers/SearchFormViewHelper.php +++ b/Classes/ViewHelpers/SearchFormViewHelper.php @@ -1,6 +1,6 @@ getMajorVersion() >= 11) { $uriBuilder = $this->renderingContext->getUriBuilder(); } else { + // @extensionScannerIgnoreLine $uriBuilder = GeneralUtility::makeInstance(ObjectManager::class)->get(UriBuilder::class); /** @var ControllerContext $controllerContext */ $controllerContext = $this->renderingContext->getControllerContext(); @@ -340,6 +341,7 @@ protected function getDefaultFieldNamePrefix() if ($versionInformation->getMajorVersion() >= 11) { $request = $this->renderingContext->getRequest(); } else { + // @extensionScannerIgnoreLine $request = $this->renderingContext->getControllerContext()->getRequest(); } if ($this->hasArgument('extensionName')) { diff --git a/Classes/ViewHelpers/SimplePrevNextViewHelper.php b/Classes/ViewHelpers/SimplePrevNextViewHelper.php index c2c8b930cb..ae99e7e5ea 100644 --- a/Classes/ViewHelpers/SimplePrevNextViewHelper.php +++ b/Classes/ViewHelpers/SimplePrevNextViewHelper.php @@ -1,5 +1,12 @@ getAspect('language'); if (isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE']) && $languageAspect->getContentId() > 0) { + // @extensionScannerIgnoreLine $overlay = $GLOBALS['TSFE']->sys_page->getRecordOverlay( 'tx_news_domain_model_news', $rawRecord, @@ -178,7 +177,7 @@ protected function getNeighbours(News $news, string $pidList, string $sortField) $queryBuilder = $connection->createQueryBuilder(); $extraWhere = [ - $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter($news->getUid(), \PDO::PARAM_INT)) + $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter($news->getUid(), \PDO::PARAM_INT)), ]; if ((bool)($this->arguments['includeInternalType'] ?? false) === false) { $extraWhere[] = $queryBuilder->expr()->neq('type', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)); @@ -212,7 +211,7 @@ protected function getNeighbours(News $news, string $pidList, string $sortField) ->andWhere(...$extraWhere) ->setMaxResults(1) ->orderBy($sortField, ($label === 'prev' ? 'desc' : 'asc')) - ->execute()->fetch(); + ->executeQuery()->fetchAssociative(); if (is_array($row)) { $data[$label] = $row; } @@ -243,7 +242,7 @@ protected function getRawRecord(int $id): ?array $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)) ) ->setMaxResults(1) - ->execute()->fetch(); + ->executeQuery()->fetchAssociative(); return $rawRecord; } } diff --git a/Classes/ViewHelpers/Tag/CountViewHelper.php b/Classes/ViewHelpers/Tag/CountViewHelper.php index c21c6fcd89..750f26c857 100644 --- a/Classes/ViewHelpers/Tag/CountViewHelper.php +++ b/Classes/ViewHelpers/Tag/CountViewHelper.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * This file is part of the "news" Extension for TYPO3 CMS. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + namespace GeorgRinger\News\ViewHelpers\Tag; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -11,13 +18,6 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface; -/** - * This file is part of the "news" Extension for TYPO3 CMS. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - */ - /** * Get usage count * @@ -70,8 +70,7 @@ public static function renderStatic( ->where( $queryBuilder->expr()->eq('tx_news_domain_model_tag.uid', $queryBuilder->createNamedParameter($arguments['tagUid'], \PDO::PARAM_INT)) ) - ->execute() - ->fetchColumn(0); + ->executeQuery()->fetchOne(); return $count; } diff --git a/Classes/ViewHelpers/TargetLinkViewHelper.php b/Classes/ViewHelpers/TargetLinkViewHelper.php index fc8dccb0cf..b665a0ac27 100644 --- a/Classes/ViewHelpers/TargetLinkViewHelper.php +++ b/Classes/ViewHelpers/TargetLinkViewHelper.php @@ -1,14 +1,14 @@ getPluginNameFromFrameworkConfiguration($extensionName, $controllerName, $actionName)) !== null) { + return $pluginName; + } + + $plugins = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'] ?? false; + if (!$plugins) { + return null; + } + $pluginNames = []; + foreach ($plugins as $pluginName => $pluginConfiguration) { + $controllers = $pluginConfiguration['controllers'] ?? []; + $controllerAliases = array_column($controllers, 'actions', 'alias'); + + foreach ($controllerAliases as $pluginControllerName => $pluginControllerActions) { + if (strtolower($pluginControllerName) !== strtolower($controllerName)) { + continue; + } + if (in_array($actionName, $pluginControllerActions, true)) { + $pluginNames[] = $pluginName; + } + } + } + return !empty($pluginNames) ? $pluginNames[0] : null; + } + + private function getPluginNameFromFrameworkConfiguration(string $extensionName, string $controllerAlias, ?string $actionName): ?string + { + if ($actionName === null) { + return null; + } + + $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); + + if (!is_string($pluginName = ($frameworkConfiguration['pluginName'] ?? null))) { + return null; + } + + $configuredExtensionName = $frameworkConfiguration['extensionName'] ?? ''; + $configuredExtensionName = is_string($configuredExtensionName) ? $configuredExtensionName : ''; + + if ($configuredExtensionName === '' || $configuredExtensionName !== $extensionName) { + return null; + } + + $configuredControllers = $frameworkConfiguration['controllerConfiguration'] ?? []; + $configuredControllers = is_array($configuredControllers) ? $configuredControllers : []; + + $configuredActionsByControllerAliases = array_column($configuredControllers, 'actions', 'alias'); + + $actions = $configuredActionsByControllerAliases[$controllerAlias] ?? []; + $actions = is_array($actions) ? $actions : []; + + return in_array($actionName, $actions, true) ? $pluginName : null; + } +} diff --git a/Classes/Xclass/InlineRecordContainerForNews.php b/Classes/Xclass/InlineRecordContainerForNews.php deleted file mode 100644 index 309bc4051f..0000000000 --- a/Classes/Xclass/InlineRecordContainerForNews.php +++ /dev/null @@ -1,105 +0,0 @@ -getLanguageService(); - $inlineConfig = $data['inlineParentConfig']; - $foreignTable = $inlineConfig['foreign_table']; - if (!isset($inlineConfig['appearance']['useXclassedVersion']) || $inlineConfig['appearance']['useXclassedVersion'] !== true || $foreignTable !== 'tt_content') { - return parent::renderForeignRecordHeader($data); - } - - $rec = $data['databaseRow']; - // Init: - $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']); - $objectId = $domObjectId . '-' . $foreignTable . '-' . $rec['uid']; - - $altText = BackendUtility::getRecordIconAltText($rec, $foreignTable); - $iconImg = '' . $this->iconFactory->getIconForRecord($foreignTable, $rec, Icon::SIZE_SMALL)->render() . ''; - - $raw = BackendUtility::getRecord('tt_content', $rec['uid']); - $renderFallback = true; - if (is_array($raw) && !empty($raw) && $raw['CType'] !== 'gridelements_pi1') { - $renderFallback = false; - $pageLayoutView = GeneralUtility::makeInstance(PageLayoutView::class); - $pageLayoutView->doEdit = false; - foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) { - $pageLayoutView->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]); - } - - $label = trim($pageLayoutView->tt_content_drawItem($raw)); - if (strpos($label, $this->getWarningLabel($raw['CType'])) !== false) { - $renderFallback = true; - } - } - - if ($renderFallback) { - $label = $data['recordTitle']; - if (!empty($label)) { - // The user function may return HTML, therefore we can't escape it - if (empty($data['processedTca']['ctrl']['formattedLabel_userFunc'])) { - $label = BackendUtility::getRecordTitlePrep($label); - } - } else { - $label = '[' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']'; - } - } - - $label = '' . $label . ''; - - $typo3Information = GeneralUtility::makeInstance(Typo3Version::class); - if ($typo3Information->getMajorVersion() === 9) { - $header = ' -
' . $iconImg . '
-
' . $label . '
-
' . $this->renderForeignRecordHeaderControl($data) . '
'; - } else { - $header = ' - -
' . $this->renderForeignRecordHeaderControl($data) . '
'; - } - - return $header; - } - - /** - * @param string $cType - * @return string - */ - protected function getWarningLabel($cType): string - { - $message = sprintf( - $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'), - $cType - ); - return htmlspecialchars($message); - } -} diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php index bafadfe6ab..150175deeb 100644 --- a/Configuration/Extbase/Persistence/Classes.php +++ b/Configuration/Extbase/Persistence/Classes.php @@ -8,7 +8,7 @@ 0 => \GeorgRinger\News\Domain\Model\NewsDefault::class, 1 => \GeorgRinger\News\Domain\Model\NewsInternal::class, 2 => \GeorgRinger\News\Domain\Model\NewsExternal::class, - ] + ], ], \GeorgRinger\News\Domain\Model\NewsDefault::class => [ 'tableName' => 'tx_news_domain_model_news', @@ -29,16 +29,16 @@ 'tableName' => 'tt_content', 'properties' => [ 'altText' => [ - 'fieldName' => 'altText' + 'fieldName' => 'altText', ], 'titleText' => [ - 'fieldName' => 'titleText' + 'fieldName' => 'titleText', ], 'colPos' => [ - 'fieldName' => 'colPos' + 'fieldName' => 'colPos', ], 'CType' => [ - 'fieldName' => 'CType' + 'fieldName' => 'CType', ], ], ], @@ -46,7 +46,7 @@ 'tableName' => 'sys_category', 'properties' => [ 'parentcategory' => [ - 'fieldName' => 'parent' + 'fieldName' => 'parent', ], ], ], diff --git a/Configuration/FlexForms/flexform_category_list.xml b/Configuration/FlexForms/flexform_category_list.xml new file mode 100644 index 0000000000..edb8bfc016 --- /dev/null +++ b/Configuration/FlexForms/flexform_category_list.xml @@ -0,0 +1,185 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.settings + + array + + + + + + + select + tree + selectTree + + + parent + + 99 + TRUE + TRUE + + + sys_category + AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting + 15 + 0 + 99 + + + + + + + + + + + + + + + + + + + + group + db + pages + 3 + 50 + 0 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.recursive.I.inherit + + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.0 + 0 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.1 + 1 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.2 + 2 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.3 + 3 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.4 + 4 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.5 + 250 + + + + + + + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + check + 1 + + + + + + + + + + + diff --git a/Configuration/FlexForms/flexform_news_date_menu.xml b/Configuration/FlexForms/flexform_news_date_menu.xml new file mode 100644 index 0000000000..c97cc5e4a5 --- /dev/null +++ b/Configuration/FlexForms/flexform_news_date_menu.xml @@ -0,0 +1,375 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.settings + + array + + + + + + + select + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.dateField.datetime + datetime + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.dateField.archive + archive + + + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.all + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.or + or + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.and + and + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.notor + notor + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.notand + notand + + + + + + + + + + + + select + tree + selectTree + + + parent + + 99 + TRUE + TRUE + + + sys_category + AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting + 15 + 0 + 99 + + + + + + + + + + check + + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.no-constraint + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.archiveRestriction.active + active + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.archiveRestriction.archived + archived + + + + + + + + + + + + 1 + + input + 15 + + + + + + + + + + 1 + + input + 15 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.no-constraint + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction.1 + 1 + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction.2 + 2 + + + + + + + + + + + + + group + db + pages + 3 + 50 + 0 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.recursive.I.inherit + + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.0 + 0 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.1 + 1 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.2 + 2 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.3 + 3 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.4 + 4 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.5 + 250 + + + + + + + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + input + 5 + num + + + + + + + + + + input + 5 + num + + + + + + + + + + check + 1 + + + + + + + + + + + diff --git a/Configuration/FlexForms/flexform_news_detail.xml b/Configuration/FlexForms/flexform_news_detail.xml new file mode 100644 index 0000000000..224e24854f --- /dev/null +++ b/Configuration/FlexForms/flexform_news_detail.xml @@ -0,0 +1,242 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.settings + + array + + + + + + + + group + db + tx_news_domain_model_news + 1 + 1 + 0 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.previewHiddenRecords.I.2 + 2 + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.previewHiddenRecords.I.1 + 1 + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.previewHiddenRecords.I.0 + 0 + + + 1 + 1 + + + + + + + + + + group + db + pages + 3 + 50 + 0 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.recursive.I.inherit + + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.0 + 0 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.1 + 1 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.2 + 2 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.3 + 3 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.4 + 4 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.5 + 250 + + + + + + + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + check + + + + + + + + + + check + 1 + + + + + + + + + + + diff --git a/Configuration/FlexForms/flexform_news_list.xml b/Configuration/FlexForms/flexform_news_list.xml new file mode 100644 index 0000000000..61b55b4b66 --- /dev/null +++ b/Configuration/FlexForms/flexform_news_list.xml @@ -0,0 +1,552 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.settings + + array + + + + + + + select + GeorgRinger\News\Hooks\ItemsProcFunc->user_orderBy + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.tstamp + tstamp + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.datetime + datetime + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.crdate + crdate + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.title + title + + + + + + + + + + + + select + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.asc + asc + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.desc + desc + + + + + + + + + + + + select + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.dateField.datetime + datetime + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.dateField.archive + archive + + + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.all + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.or + or + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.and + and + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.notor + notor + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction.notand + notand + + + + + + + + + + + + select + tree + selectTree + + + parent + + 99 + TRUE + TRUE + + + sys_category + AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting + 15 + 0 + 99 + + + + + + + + + + check + + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.no-constraint + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.archiveRestriction.active + active + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.archiveRestriction.archived + archived + + + + + + + + + + + + 1 + + input + 15 + + + + + + + + + + 1 + + input + 15 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.no-constraint + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction.1 + 1 + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction.2 + 2 + + + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.previewHiddenRecords.I.2 + 2 + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.previewHiddenRecords.I.1 + 1 + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.previewHiddenRecords.I.0 + 0 + + + 1 + 1 + + + + + + + + + + group + db + pages + 3 + 50 + 0 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.recursive.I.inherit + + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.0 + 0 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.1 + 1 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.2 + 2 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.3 + 3 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.4 + 4 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.5 + 250 + + + + + + + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + input + 5 + num + + + + + + + + + + input + 5 + num + + + + + + + + + + group + db + tx_news_domain_model_tag + 3 + 0 + 99 + + + + + + + + + + check + + + + + + + + + input + 2 + + + + + + + + + + check + + + + + + + + + + check + + + + + + + + + + check + 1 + + + + + + + + + + + diff --git a/Configuration/FlexForms/flexform_news_search_form.xml b/Configuration/FlexForms/flexform_news_search_form.xml new file mode 100644 index 0000000000..49a01247bc --- /dev/null +++ b/Configuration/FlexForms/flexform_news_search_form.xml @@ -0,0 +1,83 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + tx_news_domain_model_tag + 3 + 0 + 99 + + + + + + + + + + + diff --git a/Configuration/FlexForms/flexform_news_selected_list.xml b/Configuration/FlexForms/flexform_news_selected_list.xml new file mode 100644 index 0000000000..d2fc927af7 --- /dev/null +++ b/Configuration/FlexForms/flexform_news_selected_list.xml @@ -0,0 +1,315 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.settings + + array + + + + + + + + group + db + tx_news_domain_model_news + 3 + 1 + + + + + + + + + + select + GeorgRinger\News\Hooks\ItemsProcFunc->user_orderBy + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.tstamp + tstamp + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.datetime + datetime + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.crdate + crdate + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.title + title + + + + + + + + + + + + select + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.asc + asc + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.desc + desc + + + + + + + + + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + input + 5 + num + + + + + + + + + + input + 5 + num + + + + + + + + + + group + db + tx_news_domain_model_tag + 3 + 0 + 99 + + + + + + + + + + check + + + + + + + + + input + 2 + + + + + + + + + + check + + + + + + + + + + check + + + + + + + + + + check + 1 + + + + + + + + + + + diff --git a/Configuration/FlexForms/flexform_tag_list.xml b/Configuration/FlexForms/flexform_tag_list.xml new file mode 100644 index 0000000000..dceb97f09a --- /dev/null +++ b/Configuration/FlexForms/flexform_tag_list.xml @@ -0,0 +1,233 @@ + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.settings + + array + + + + + + + select + GeorgRinger\News\Hooks\ItemsProcFunc->user_orderBy + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.tstamp + tstamp + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.crdate + crdate + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.title + title + + + + + + + + + + + + select + selectSingle + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.asc + asc + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.desc + desc + + + + + + + + + + + + group + db + pages + 3 + 50 + 0 + + + + + + + + + + select + selectSingle + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.recursive.I.inherit + + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.0 + 0 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.1 + 1 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.2 + 2 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.3 + 3 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.4 + 4 + + + LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.5 + 250 + + + + + + + + + + + + + LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_tab.additional + + array + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + group + db + pages + 1 + 1 + 0 + + + + + + + + + + + group + db + tx_news_domain_model_tag + 3 + 0 + 99 + + + + + + + + + + check + 1 + + + + + + + + + + + diff --git a/Configuration/Icons.php b/Configuration/Icons.php new file mode 100644 index 0000000000..07ed2906f4 --- /dev/null +++ b/Configuration/Icons.php @@ -0,0 +1,33 @@ + 'ext-news-folder-tree.svg', + 'apps-pagetree-page-contains-news' => 'ext-news-page-tree.svg', + 'ext-news-wizard-icon' => 'plugin-list-with-detail.svg', + 'ext-news-plugin-news-list' => 'plugin-list-with-detail.svg', + 'ext-news-plugin-news-list-sticky' => 'plugin-list.svg', + 'ext-news-plugin-detail' => 'plugin-detail.svg', + 'ext-news-plugin-news-date-menu' => 'plugin-date-menu.svg', + 'ext-news-plugin-news-search-form' => 'plugin-search-form.svg', + 'ext-news-plugin-news-search-result' => 'plugin-search-results.svg', + 'ext-news-plugin-news-selected-list' => 'plugin-selected-list.svg', + 'ext-news-plugin-category-list' => 'plugin-category-menu.svg', + 'ext-news-plugin-tag-list' => 'plugin-tag-menu.svg', + 'ext-news-type-default' => 'news_domain_model_news.svg', + 'ext-news-type-internal' => 'news_domain_model_news_internal.svg', + 'ext-news-type-external' => 'news_domain_model_news_external.svg', + 'ext-news-tag' => 'news_domain_model_tag.svg', + 'ext-news-link' => 'news_domain_model_link.svg', + 'ext-news-donation' => 'donation.svg', + 'ext-news-paypal' => 'donation_paypal.svg', + 'ext-news-patreon' => 'donation_patreon.svg', + 'ext-news-amazon' => 'donation_amazon.svg', + 'ext-news-doublecheck' => 'double_check.svg', + ] as $identifier => $path) { + $iconList[$identifier] = [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:news/Resources/Public/Icons/' . $path, + ]; +} + +return $iconList; diff --git a/Configuration/Services.php b/Configuration/Services.php index 85c3c1637a..e5bad37f05 100644 --- a/Configuration/Services.php +++ b/Configuration/Services.php @@ -2,11 +2,10 @@ declare(strict_types=1); -use GeorgRinger\News\Backend\FormDataProvider\NewsFlexFormManipulation; use GeorgRinger\News\Hooks\Backend\RecordListQueryHook; use GeorgRinger\News\Hooks\FlexformHook; use GeorgRinger\News\Hooks\ItemsProcFunc; -use GeorgRinger\News\Hooks\PageLayoutView; +use GeorgRinger\News\Hooks\PluginPreviewRenderer; use GeorgRinger\News\Updates\NewsSlugUpdater; use GeorgRinger\News\Updates\RealurlAliasNewsSlugUpdater; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -14,11 +13,10 @@ use TYPO3\CMS\Core\DependencyInjection; return function (ContainerConfigurator $container, ContainerBuilder $containerBuilder) { - $containerBuilder->registerForAutoconfiguration(NewsFlexFormManipulation::class)->addTag('news.NewsFlexFormManipulation'); $containerBuilder->registerForAutoconfiguration(RecordListQueryHook::class)->addTag('news.RecordListQueryHook'); $containerBuilder->registerForAutoconfiguration(FlexformHook::class)->addTag('news.BackendUtility'); $containerBuilder->registerForAutoconfiguration(ItemsProcFunc::class)->addTag('news.ItemsProcFunc'); - $containerBuilder->registerForAutoconfiguration(PageLayoutView::class)->addTag('news.PageLayoutView'); + $containerBuilder->registerForAutoconfiguration(PluginPreviewRenderer::class)->addTag('news.PageLayoutView'); $containerBuilder->registerForAutoconfiguration(NewsSlugUpdater::class)->addTag('news.NewsSlugUpdater'); $containerBuilder->registerForAutoconfiguration(RealurlAliasNewsSlugUpdater::class)->addTag('news.RealurlAliasNewsSlugUpdater'); diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 41a8834f3c..5ef16d8f88 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -42,3 +42,17 @@ services: command: 'news:rebuildProxyClasses' schedulable: false description: 'Rebuild the proxy classes used to extend EXT:news' + + GeorgRinger\News\Event\Listener\ModifyFileReferenceControlsEventListener: + tags: + - name: event.listener + identifier: 'ext-news/modify-inline-element-control' + method: 'modifyControls' + event: TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceControlsEvent + + GeorgRinger\News\Event\Listener\ModifyDatabaseQueryForContentEventListener: + tags: + - name: event.listener + identifier: 'ext-news/modify-database-query-for-content' + method: 'modify' + event: TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForContentEvent \ No newline at end of file diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index 90530ba5a9..086729b9e5 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -1,17 +1,17 @@ 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:news-folder', 1 => 'news', - 2 => 'apps-pagetree-folder-contains-news' + 2 => 'apps-pagetree-folder-contains-news', ]; $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [ 0 => 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:news-page', 1 => 'newsplugins', - 2 => 'apps-pagetree-page-contains-news' + 2 => 'apps-pagetree-page-contains-news', ]; $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['contains-newsplugins'] = 'apps-pagetree-page-contains-news'; diff --git a/Configuration/TCA/Overrides/sys_category.php b/Configuration/TCA/Overrides/sys_category.php index ea1a99fddb..84937c584e 100644 --- a/Configuration/TCA/Overrides/sys_category.php +++ b/Configuration/TCA/Overrides/sys_category.php @@ -1,10 +1,45 @@ [ + 'allowLanguageSynchronization' => true, + ], + 'appearance' => [ + 'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference', + 'showPossibleLocalizationRecords' => true, + 'showAllLocalizationLink' => true, + 'showSynchronizationLink' => true, + ], + 'foreign_match_fields' => [ + 'fieldname' => 'images', + 'tablenames' => 'sys_category', + 'table_local' => 'sys_file', + ], +]; + +$versionInformation = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class); +if ($versionInformation->getMajorVersion() > 11) { + $imageConfiguration = [ + 'type' => 'file', + 'appearance' => $imageSettings['appearance'], + 'behaviour' => $imageSettings['behaviour'], + 'allowed' => 'common-image-types', + ]; +} else { + /** @noinspection PhpDeprecationInspection */ + // @extensionScannerIgnoreLine + $imageConfiguration = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'image', + $imageSettings, + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ); +} + /** * Add extra fields to the sys_category record */ @@ -12,51 +47,31 @@ 'pid' => [ 'label' => 'pid', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'sorting' => [ 'label' => 'sorting', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'crdate' => [ 'label' => 'crdate', 'config' => [ 'type' => 'passthrough', - ] + ], ], 'tstamp' => [ 'label' => 'tstamp', 'config' => [ 'type' => 'passthrough', - ] + ], ], 'images' => [ 'exclude' => true, 'label' => $ll . 'tx_news_domain_model_category.image', - 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( - 'images', - [ - 'behaviour' => [ - 'allowLanguageSynchronization' => true, - ], - 'appearance' => [ - 'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference', - 'showPossibleLocalizationRecords' => true, - 'showRemovedLocalizationRecords' => true, - 'showAllLocalizationLink' => true, - 'showSynchronizationLink' => true - ], - 'foreign_match_fields' => [ - 'fieldname' => 'images', - 'tablenames' => 'sys_category', - 'table_local' => 'sys_file', - ], - ], - $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] - ) + 'config' => $imageConfiguration, ], 'single_pid' => [ 'exclude' => true, @@ -71,12 +86,12 @@ 'suggestOptions' => [ 'default' => [ 'searchWholePhrase' => true, - ] + ], ], 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'shortcut' => [ 'exclude' => true, @@ -91,24 +106,24 @@ 'suggestOptions' => [ 'default' => [ 'searchWholePhrase' => true, - ] + ], ], 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'import_id' => [ 'label' => $ll . 'tx_news_domain_model_news.import_id', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'import_source' => [ 'label' => $ll . 'tx_news_domain_model_news.import_source', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'seo_headline' => [ 'exclude' => true, @@ -139,7 +154,7 @@ 'enableRichtext' => true, ], ], - 'slug' =>[ + 'slug' => [ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:pages.slug', 'displayCond' => 'VERSION:IS:false', @@ -149,13 +164,13 @@ 'generatorOptions' => [ 'fields' => ['title'], 'replacements' => [ - '/' => '-' + '/' => '-', ], ], 'fallbackCharacter' => '-', 'eval' => $configuration->getSlugBehaviour(), - 'default' => '' - ] + 'default' => '', + ], ], ]; diff --git a/Configuration/TCA/Overrides/sys_file_reference.php b/Configuration/TCA/Overrides/sys_file_reference.php index eb97431211..d97e85ac1e 100644 --- a/Configuration/TCA/Overrides/sys_file_reference.php +++ b/Configuration/TCA/Overrides/sys_file_reference.php @@ -1,6 +1,6 @@ isAdvancedMediaPreview()) { @@ -17,7 +17,7 @@ } else { $fieldConfig = [ 'type' => 'check', - 'default' => 0 + 'default' => 0, ]; } @@ -25,7 +25,7 @@ 'showinpreview' => [ 'exclude' => true, 'label' => 'LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:tx_news_domain_model_media.showinviews', - 'config' => $fieldConfig + 'config' => $fieldConfig, ], ]; diff --git a/Configuration/TCA/Overrides/sys_reaction.php b/Configuration/TCA/Overrides/sys_reaction.php new file mode 100644 index 0000000000..f2b1edcbb4 --- /dev/null +++ b/Configuration/TCA/Overrides/sys_reaction.php @@ -0,0 +1,13 @@ + $fakeField, 'config' => [ 'type' => 'passthrough', - ] + ], ]; } } @@ -35,8 +63,8 @@ 'tx_news_related_news' => [ 'label' => 'tx_news_related_news', 'config' => [ - 'type' => 'passthrough' - ] - ] + 'type' => 'passthrough', + ], + ], ]; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $newFields); diff --git a/Configuration/TCA/Overrides/tx_news_domain_model_news.php b/Configuration/TCA/Overrides/tx_news_domain_model_news.php index bf4bbe3f58..1ec8bb2277 100644 --- a/Configuration/TCA/Overrides/tx_news_domain_model_news.php +++ b/Configuration/TCA/Overrides/tx_news_domain_model_news.php @@ -1,6 +1,6 @@ 'selectSingle', - 'type' => 'select' + 'type' => 'select', ], 'exclude' => true, - 'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.sitemap_changefreq' + 'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.sitemap_changefreq', ], 'sitemap_priority' => [ 'config' => [ @@ -39,21 +39,21 @@ ['0.7', '0.7'], ['0.8', '0.8'], ['0.9', '0.9'], - ['1.0', '1.0'] + ['1.0', '1.0'], ], 'renderType' => 'selectSingle', 'type' => 'select', 'default' => '0.5', ], 'exclude' => true, - 'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.sitemap_priority' - ] + 'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.sitemap_priority', + ], ] ); $GLOBALS['TCA']['tx_news_domain_model_news']['palettes']['sitemap'] = [ 'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.palettes.sitemap', - 'showitem' => 'sitemap_changefreq,sitemap_priority' + 'showitem' => 'sitemap_changefreq,sitemap_priority', ]; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( diff --git a/Configuration/TCA/Overrides/z_misc_11_adoptions.php b/Configuration/TCA/Overrides/z_misc_11_adoptions.php deleted file mode 100644 index a70d1bbb48..0000000000 --- a/Configuration/TCA/Overrides/z_misc_11_adoptions.php +++ /dev/null @@ -1,33 +0,0 @@ -getMajorVersion() === 11) { - foreach (['link', 'news', 'tag'] as $tableSuffix) { - $GLOBALS['TCA']['tx_news_domain_model_' . $tableSuffix]['columns']['sys_language_uid']['config'] = [ - 'type' => 'language' - ]; - } - - $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['categories']['config'] = [ - 'type' => 'category' - ]; - - $showRemovedLocalizationRecordsFields = [ - 'sys_category' => ['images'], - 'tx_news_domain_model_news' => ['related_links', 'content_elements', 'fal_media', 'fal_related_files'] - ]; - - foreach ($showRemovedLocalizationRecordsFields as $tableName => $fields) { - foreach ($fields as $field) { - unset($GLOBALS['TCA'][$tableName]['columns'][$field]['config']['appearance']['showRemovedLocalizationRecords']); - } - } - - // Remove setting when v10 is not supported anymore - // see https://github.com/georgringer/news/commit/469511293c5bbf72cb60ac7445e790411bc17931 - unset($GLOBALS['TCA']['tx_news_domain_model_news']['ctrl']['thumbnail']); - } -}); diff --git a/Configuration/TCA/Overrides/z_misc_12_adoptions.php b/Configuration/TCA/Overrides/z_misc_12_adoptions.php new file mode 100644 index 0000000000..395617d74a --- /dev/null +++ b/Configuration/TCA/Overrides/z_misc_12_adoptions.php @@ -0,0 +1,59 @@ +getMajorVersion() > 11) { + foreach (['news', 'link', 'tag'] as $tableSuffix) { + // remove cruser_id + unset($GLOBALS['TCA']['tx_news_domain_model_' . $tableSuffix]['ctrl']['cruser_id']); + // set datetime for tstamp/crdate + foreach (['tstamp', 'crdate'] as $dateField) { + $GLOBALS['TCA']['tx_news_domain_model_' . $tableSuffix]['columns'][$dateField]['config'] = [ + 'type' => 'datetime', + ]; + } + } + // set datetime for various date fields + foreach (['starttime', 'endtime', 'archive', 'datetime'] as $dateField) { + $GLOBALS['TCA']['tx_news_domain_model_news']['columns'][$dateField]['config'] = [ + 'type' => 'datetime', + ]; + } + $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['archive']['config']['format'] = $configuration->getArchiveDate(); + $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['datetime']['config']['required'] = $configuration->getDateTimeRequired(); + + // link fields + $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['internalurl']['config'] = [ + 'type' => 'link', + 'required' => true, + ]; + $GLOBALS['TCA']['tx_news_domain_model_link']['columns']['uri']['config'] = [ + 'type' => 'link', + 'placeholder' => $ll . 'tx_news_domain_model_link.uri.placeholder', + 'required' => 'true', + 'softref' => 'typolink', + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ], + ]; + + // internal type + foreach (['sys_category' => ['single_pid', 'shortcut'], 'tx_news_domain_model_news' => ['l10n_parent', 'related_from', 'related']] as $table => $fields) { + foreach ($fields as $field) { + unset($GLOBALS['TCA'][$table]['columns'][$field]['config']['internal_type']); + } + } + + // required fields + foreach (['tx_news_domain_model_link' => ['uri'], 'tx_news_domain_model_news' => ['title', 'externalurl'], 'tx_news_domain_model_tag' => ['title']] as $table => $fields) { + foreach ($fields as $field) { + $GLOBALS['TCA'][$table]['columns'][$field]['config']['required'] = true; + $GLOBALS['TCA'][$table]['columns'][$field]['config']['eval'] = str_replace('required', '', $GLOBALS['TCA'][$table]['columns'][$field]['config']['required']); + } + } + } +}); diff --git a/Configuration/TCA/tx_news_domain_model_link.php b/Configuration/TCA/tx_news_domain_model_link.php index 1f8047f053..ebe7e4ce1c 100644 --- a/Configuration/TCA/tx_news_domain_model_link.php +++ b/Configuration/TCA/tx_news_domain_model_link.php @@ -1,6 +1,6 @@ 'hidden', ], 'typeicon_classes' => [ - 'default' => 'ext-news-link' + 'default' => 'ext-news-link', ], 'hideTable' => true, + 'security' => [ + 'ignorePageTypeRestriction' => true, + ], ], 'columns' => [ 'pid' => [ 'label' => 'pid', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'crdate' => [ 'label' => 'crdate', @@ -44,7 +47,7 @@ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'datetime', - ] + ], ], 'tstamp' => [ 'label' => 'tstamp', @@ -52,24 +55,14 @@ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'datetime', - ] + ], ], 'sys_language_uid' => [ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'special' => 'languages', - 'items' => [ - [ - 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', - -1, - 'flags-multiple' - ], - ], - 'default' => 0, - ] + 'type' => 'language', + ], ], 'l10n_parent' => [ 'displayCond' => 'FIELD:sys_language_uid:>:0', @@ -83,26 +76,26 @@ 'foreign_table' => 'tx_news_domain_model_link', 'foreign_table_where' => 'AND tx_news_domain_model_link.pid=###CURRENT_PID### AND tx_news_domain_model_link.sys_language_uid IN (-1,0)', 'default' => 0, - ] + ], ], 'l10n_source' => [ 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'l10n_diffsource' => [ 'config' => [ 'type' => 'passthrough', - 'default' => '' - ] + 'default' => '', + ], ], 'hidden' => [ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', 'config' => [ 'type' => 'check', - 'default' => 0 - ] + 'default' => 0, + ], ], 'title' => [ 'exclude' => false, @@ -113,7 +106,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'description' => [ 'exclude' => true, @@ -125,7 +118,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'uri' => [ 'exclude' => false, @@ -140,13 +133,13 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], ], 'types' => [ 0 => [ - 'showitem' => 'uri, --palette--;;paletteCore,title, --palette--;;paletteDescription' - ] + 'showitem' => 'uri, --palette--;;paletteCore,title, --palette--;;paletteDescription', + ], ], 'palettes' => [ 'paletteCore' => [ @@ -154,6 +147,6 @@ ], 'paletteDescription' => [ 'showitem' => 'description', - ] - ] + ], + ], ]; diff --git a/Configuration/TCA/tx_news_domain_model_news.php b/Configuration/TCA/tx_news_domain_model_news.php index 26a0f6567e..6688a46ebd 100644 --- a/Configuration/TCA/tx_news_domain_model_news.php +++ b/Configuration/TCA/tx_news_domain_model_news.php @@ -1,11 +1,120 @@ [ + 'allowLanguageSynchronization' => true, + ], + 'appearance' => [ + 'createNewRelationLinkTitle' => $ll . 'tx_news_domain_model_news.fal_media.add', + 'showPossibleLocalizationRecords' => true, + 'showAllLocalizationLink' => true, + 'showSynchronizationLink' => true, + ], + 'foreign_match_fields' => [ + 'fieldname' => 'fal_media', + 'tablenames' => 'tx_news_domain_model_news', + 'table_local' => 'sys_file', + ], + // custom configuration for displaying fields in the overlay/reference table + // to use the newsPalette and imageoverlayPalette instead of the basicoverlayPalette + 'overrideChildTca' => [ + 'types' => [ + \TYPO3\CMS\Core\Resource\File::FILETYPE_UNKNOWN => [ + 'showitem' => ' + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, + --palette--;;imageoverlayPalette, + --palette--;;filePalette', + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ + 'showitem' => ' + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, + --palette--;;imageoverlayPalette, + --palette--;;filePalette', + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + 'showitem' => ' + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, + --palette--;;imageoverlayPalette, + --palette--;;filePalette', + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ + 'showitem' => ' + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, + --palette--;;audioOverlayPalette, + --palette--;;filePalette', + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + 'showitem' => ' + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, + --palette--;;videoOverlayPalette, + --palette--;;filePalette', + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ + 'showitem' => ' + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, + --palette--;;imageoverlayPalette, + --palette--;;filePalette', + ], + ], + ], +]; +$imageSettingsFalRelatedFiles = [ + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ], + 'appearance' => [ + 'createNewRelationLinkTitle' => $ll . 'tx_news_domain_model_news.fal_related_files.add', + 'showPossibleLocalizationRecords' => true, + 'showAllLocalizationLink' => true, + 'showSynchronizationLink' => true, + ], + 'inline' => [ + 'inlineOnlineMediaAddButtonStyle' => 'display:none', + ], + 'foreign_match_fields' => [ + 'fieldname' => 'fal_related_files', + 'tablenames' => 'tx_news_domain_model_news', + 'table_local' => 'sys_file', + ], +]; + +$versionInformation = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class); +if ($versionInformation->getMajorVersion() > 11) { + $imageConfigurationFalMedia = [ + 'type' => 'file', + 'appearance' => $imageSettingsFalMedia['appearance'], + 'behaviour' => $imageSettingsFalMedia['behaviour'], + 'overrideChildTca' => $imageSettingsFalMedia['overrideChildTca'], + 'allowed' => 'common-image-types', + ]; + $imageConfigurationFalRelatedFiles = [ + 'type' => 'file', + 'appearance' => $imageSettingsFalRelatedFiles['appearance'], + 'behaviour' => $imageSettingsFalRelatedFiles['behaviour'], + 'inline' => $imageSettingsFalRelatedFiles['inline'], + ]; +} else { + /** @noinspection PhpDeprecationInspection */ + // @extensionScannerIgnoreLine + $imageConfigurationFalMedia = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'fal_media', + $imageSettingsFalMedia, + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ); + /** @noinspection PhpDeprecationInspection */ + // @extensionScannerIgnoreLine + $imageConfigurationFalRelatedFiles = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'fal_related_files', + $imageSettingsFalRelatedFiles, + ); +} + $tx_news_domain_model_news = [ 'ctrl' => [ 'title' => $ll . 'tx_news_domain_model_news', @@ -42,25 +151,17 @@ ], 'iconfile' => 'EXT:news/Resources/Public/Icons/news_domain_model_news.svg', 'searchFields' => 'uid,title', - 'thumbnail' => $configuration->isMediaPreview() ? 'fal_media' : '', + 'security' => [ + 'ignorePageTypeRestriction' => true, + ], ], 'columns' => [ 'sys_language_uid' => [ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'special' => 'languages', - 'items' => [ - [ - 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', - -1, - 'flags-multiple' - ], - ], - 'default' => 0, - ] + 'type' => 'language', + ], ], 'l10n_parent' => [ 'displayCond' => 'FIELD:sys_language_uid:>:0', @@ -77,14 +178,14 @@ ], 'l10n_source' => [ 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'l10n_diffsource' => [ 'config' => [ 'type' => 'passthrough', - 'default' => '' - ] + 'default' => '', + ], ], 'hidden' => [ 'exclude' => true, @@ -97,21 +198,21 @@ [ 0 => '', 1 => '', - ] + ], ], - ] + ], ], 'cruser_id' => [ 'label' => 'cruser_id', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'pid' => [ 'label' => 'pid', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'crdate' => [ 'label' => 'crdate', @@ -119,7 +220,7 @@ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'datetime', - ] + ], ], 'tstamp' => [ 'label' => 'tstamp', @@ -127,13 +228,13 @@ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'datetime', - ] + ], ], 'sorting' => [ 'label' => 'sorting', 'config' => [ 'type' => 'passthrough', - ] + ], ], 'starttime' => [ 'exclude' => true, @@ -147,7 +248,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'endtime' => [ 'exclude' => true, @@ -161,7 +262,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'fe_group' => [ 'exclude' => true, @@ -199,7 +300,7 @@ 'size' => 60, 'max' => 255, 'eval' => 'required', - ] + ], ], 'alternative_title' => [ 'exclude' => true, @@ -207,7 +308,7 @@ 'config' => [ 'type' => 'input', 'size' => 30, - ] + ], ], 'teaser' => [ 'exclude' => true, @@ -217,7 +318,7 @@ 'cols' => 60, 'rows' => 5, 'enableRichtext' => $configuration->getRteForTeaser(), - ] + ], ], 'bodytext' => [ 'exclude' => false, @@ -228,7 +329,7 @@ 'rows' => 5, 'softref' => 'typolink_tag,email[subst],url', 'enableRichtext' => true, - ] + ], ], 'datetime' => [ 'exclude' => false, @@ -238,7 +339,7 @@ 'renderType' => 'inputDateTime', 'size' => 16, 'eval' => 'datetime,int' . ($configuration->getDateTimeRequired() ? ',required' : ''), - ] + ], ], 'archive' => [ 'exclude' => true, @@ -249,8 +350,8 @@ 'renderType' => 'inputDateTime', 'size' => 30, 'eval' => $configuration->getArchiveDate() . ',int', - 'default' => 0 - ] + 'default' => 0, + ], ], 'author' => [ 'exclude' => true, @@ -261,7 +362,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'author_email' => [ 'exclude' => true, @@ -272,7 +373,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'categories' => [ 'exclude' => true, @@ -303,7 +404,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'related' => [ 'exclude' => true, @@ -321,13 +422,13 @@ 'suggestOptions' => [ 'default' => [ 'suggestOptions' => true, - 'addWhere' => ' AND tx_news_domain_model_news.uid != ###THIS_UID###' - ] + 'addWhere' => ' AND tx_news_domain_model_news.uid != ###THIS_UID###', + ], ], 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'related_from' => [ 'exclude' => true, @@ -341,7 +442,7 @@ 'maxitems' => 100, 'MM' => 'tx_news_domain_model_news_related_mm', 'readOnly' => 1, - ] + ], ], 'related_links' => [ 'exclude' => true, @@ -361,17 +462,16 @@ 'levelLinksPosition' => 'bottom', 'useSortable' => true, 'showPossibleLocalizationRecords' => true, - 'showRemovedLocalizationRecords' => true, 'showAllLocalizationLink' => true, 'showSynchronizationLink' => true, 'enabledControls' => [ 'info' => false, - ] + ], ], 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'type' => [ 'exclude' => false, @@ -391,7 +491,7 @@ ], 'size' => 1, 'maxitems' => 1, - ] + ], ], 'keywords' => [ 'exclude' => true, @@ -404,7 +504,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'description' => [ 'exclude' => true, @@ -416,7 +516,7 @@ 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'internalurl' => [ 'exclude' => false, @@ -427,8 +527,8 @@ 'size' => 30, 'max' => 255, 'eval' => 'trim,required', - 'softref' => 'typolink' - ] + 'softref' => 'typolink', + ], ], 'externalurl' => [ 'exclude' => false, @@ -437,8 +537,8 @@ 'type' => 'input', 'size' => 50, 'eval' => 'required', - 'softref' => 'typolink' - ] + 'softref' => 'typolink', + ], ], 'istopnews' => [ 'exclude' => true, @@ -451,9 +551,9 @@ [ 0 => '', 1 => '', - ] + ], ], - ] + ], ], 'editlock' => [ 'displayCond' => 'HIDE_FOR_NON_ADMINS', @@ -466,12 +566,12 @@ [ 0 => '', 1 => '', - ] + ], ], 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'content_elements' => [ 'exclude' => true, @@ -485,23 +585,21 @@ 'minitems' => 0, 'maxitems' => 99, 'appearance' => [ - 'useXclassedVersion' => $configuration->getContentElementPreview(), 'collapseAll' => true, 'expandSingle' => true, 'levelLinksPosition' => 'bottom', 'useSortable' => true, 'showPossibleLocalizationRecords' => true, - 'showRemovedLocalizationRecords' => true, 'showAllLocalizationLink' => true, 'showSynchronizationLink' => true, 'enabledControls' => [ 'info' => false, - ] + ], ], 'behaviour' => [ 'allowLanguageSynchronization' => true, ], - ] + ], ], 'tags' => [ 'exclude' => true, @@ -534,130 +632,46 @@ 'generatorOptions' => [ 'fields' => ['title'], 'replacements' => [ - '/' => '-' + '/' => '-', ], ], 'fallbackCharacter' => '-', 'eval' => $configuration->getSlugBehaviour(), 'default' => '', 'appearance' => [ - 'prefix' => \GeorgRinger\News\Backend\FormEngine\SlugPrefix::class . '->getPrefix' - ] - ] + 'prefix' => \GeorgRinger\News\Backend\FormEngine\SlugPrefix::class . '->getPrefix', + ], + ], ], 'import_id' => [ 'label' => $ll . 'tx_news_domain_model_news.import_id', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'import_source' => [ 'label' => $ll . 'tx_news_domain_model_news.import_source', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'fal_media' => [ 'exclude' => true, 'label' => $ll . 'tx_news_domain_model_news.fal_media', - 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( - 'fal_media', - [ - 'behaviour' => [ - 'allowLanguageSynchronization' => true, - ], - 'appearance' => [ - 'createNewRelationLinkTitle' => $ll . 'tx_news_domain_model_news.fal_media.add', - 'showPossibleLocalizationRecords' => true, - 'showRemovedLocalizationRecords' => true, - 'showAllLocalizationLink' => true, - 'showSynchronizationLink' => true - ], - 'foreign_match_fields' => [ - 'fieldname' => 'fal_media', - 'tablenames' => 'tx_news_domain_model_news', - 'table_local' => 'sys_file', - ], - // custom configuration for displaying fields in the overlay/reference table - // to use the newsPalette and imageoverlayPalette instead of the basicoverlayPalette - 'overrideChildTca' => [ - 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_UNKNOWN => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, - --palette--;;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, - --palette--;;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, - --palette--;;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, - --palette--;;audioOverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, - --palette--;;videoOverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ - 'showitem' => ' - --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;newsPalette, - --palette--;;imageoverlayPalette, - --palette--;;filePalette' - ] - ], - ], - ], - $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'] - ) + 'config' => $imageConfigurationFalMedia, ], 'fal_related_files' => [ 'exclude' => true, 'label' => $ll . 'tx_news_domain_model_news.fal_related_files', - 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( - 'fal_related_files', - [ - 'behaviour' => [ - 'allowLanguageSynchronization' => true, - ], - 'appearance' => [ - 'createNewRelationLinkTitle' => $ll . 'tx_news_domain_model_news.fal_related_files.add', - 'showPossibleLocalizationRecords' => true, - 'showRemovedLocalizationRecords' => true, - 'showAllLocalizationLink' => true, - 'showSynchronizationLink' => true - ], - 'inline' => [ - 'inlineOnlineMediaAddButtonStyle' => 'display:none' - ], - 'foreign_match_fields' => [ - 'fieldname' => 'fal_related_files', - 'tablenames' => 'tx_news_domain_model_news', - 'table_local' => 'sys_file', - ], - ] - ) + 'config' => $imageConfigurationFalRelatedFiles, ], 'notes' => [ 'label' => $ll . 'notes', 'config' => [ 'type' => 'text', 'rows' => 10, - 'cols' => 48 - ] + 'cols' => 48, + ], ], ], 'types' => [ @@ -687,7 +701,7 @@ --palette--;;paletteAccess, --div--;' . $ll . 'notes, notes, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,' + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,', ], // internal url '1' => [ @@ -713,7 +727,7 @@ --palette--;;paletteAccess, --div--;' . $ll . 'notes, notes, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,' + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,', ], // external url '2' => [ @@ -739,7 +753,7 @@ --palette--;;paletteAccess, --div--;' . $ll . 'notes, notes, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,' + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,', ], ], 'palettes' => [ @@ -785,7 +799,7 @@ path_segment ', ], - ] + ], ]; // category restriction based on settings in extension manager diff --git a/Configuration/TCA/tx_news_domain_model_tag.php b/Configuration/TCA/tx_news_domain_model_tag.php index 8a77d490c0..c11689da6e 100644 --- a/Configuration/TCA/tx_news_domain_model_tag.php +++ b/Configuration/TCA/tx_news_domain_model_tag.php @@ -1,6 +1,6 @@ 'hidden', ], 'typeicon_classes' => [ - 'default' => 'ext-news-tag' + 'default' => 'ext-news-tag', ], 'searchFields' => 'uid,title', + 'security' => [ + 'ignorePageTypeRestriction' => true, + ], ], 'columns' => [ 'sys_language_uid' => [ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'special' => 'languages', - 'items' => [ - [ - 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', - -1, - 'flags-multiple' - ], - ], - 'default' => 0, - ] + 'type' => 'language', + ], ], 'l10n_parent' => [ 'displayCond' => 'FIELD:sys_language_uid:>:0', @@ -63,24 +56,24 @@ ], ], 'default' => 0, - ] + ], ], 'l10n_source' => [ 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'l10n_diffsource' => [ 'config' => [ 'type' => 'passthrough', - 'default' => '' - ] + 'default' => '', + ], ], 'pid' => [ 'label' => 'pid', 'config' => [ - 'type' => 'passthrough' - ] + 'type' => 'passthrough', + ], ], 'crdate' => [ 'label' => 'crdate', @@ -88,7 +81,7 @@ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'datetime', - ] + ], ], 'tstamp' => [ 'label' => 'tstamp', @@ -96,15 +89,15 @@ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'datetime', - ] + ], ], 'hidden' => [ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', 'config' => [ 'type' => 'check', - 'default' => 0 - ] + 'default' => 0, + ], ], 'title' => [ 'exclude' => false, @@ -113,7 +106,7 @@ 'type' => 'input', 'size' => 30, 'eval' => 'required,unique,trim', - ] + ], ], 'slug' => [ 'exclude' => true, @@ -125,13 +118,13 @@ 'generatorOptions' => [ 'fields' => ['title'], 'replacements' => [ - '/' => '-' + '/' => '-', ], ], 'fallbackCharacter' => '-', 'eval' => $configuration->getSlugBehaviour(), - 'default' => '' - ] + 'default' => '', + ], ], 'seo_headline' => [ 'exclude' => true, @@ -167,8 +160,8 @@ 'config' => [ 'type' => 'text', 'rows' => 10, - 'cols' => 48 - ] + 'cols' => 48, + ], ], ], 'types' => [ @@ -179,8 +172,8 @@ notes, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, - --palette--;;paletteLanguage,' - ] + --palette--;;paletteLanguage,', + ], ], 'palettes' => [ 'paletteCore' => [ @@ -191,5 +184,5 @@ sys_language_uid;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:sys_language_uid_formlabel,l10n_parent, l10n_diffsource, ', ], - ] + ], ]; diff --git a/Configuration/TSconfig/ContentElementWizard.tsconfig b/Configuration/TSconfig/ContentElementWizard.tsconfig index 67611554ff..01c762b6b9 100644 --- a/Configuration/TSconfig/ContentElementWizard.tsconfig +++ b/Configuration/TSconfig/ContentElementWizard.tsconfig @@ -1,13 +1,89 @@ -mod.wizards.newContentElement.wizardItems.plugins { - elements { - news { - iconIdentifier = ext-news-wizard-icon - title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pi1_title - description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pi1_plus_wiz_description - tt_content_defValues { - CType = list - list_type = news_pi1 - } - } - } +mod.wizards.newContentElement.wizardItems.ext-news { + header = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pi1_title + after = plugins,common,forms,menu + before = special + elements { + news_list { + iconIdentifier = ext-news-plugin-news-list + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_list.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_list.description + tt_content_defValues { + CType = news_pi1 + } + } + + news_list_sticky { + iconIdentifier = ext-news-plugin-news-list-sticky + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_list_sticky.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_list_sticky.description + tt_content_defValues { + CType = news_newsliststicky + } + } + + news_detail { + iconIdentifier = ext-news-plugin-detail + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_detail.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_detail.description + tt_content_defValues { + CType = news_newsdetail + } + } + + news_selectedlist { + iconIdentifier = ext-news-plugin-news-selected-list + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_selected_list.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_selected_list.description + tt_content_defValues { + CType = news_newsselectedlist + } + } + + news_datemenu { + iconIdentifier = ext-news-plugin-news-date-menu + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_date_menu.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_date_menu.description + tt_content_defValues { + CType = news_newsdatemenu + } + } + + categorylist { + iconIdentifier = ext-news-plugin-category-list + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.category_list.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.category_list.description + tt_content_defValues { + CType = news_categorylist + } + } + + news_searchform { + iconIdentifier = ext-news-plugin-news-search-form + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_search_form.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_search_form.description + tt_content_defValues { + CType = news_newssearchform + } + } + + news_searchresult { + iconIdentifier = ext-news-plugin-news-search-result + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_search_result.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.news_search_result.description + tt_content_defValues { + CType = news_newssearchresult + } + } + + taglist { + iconIdentifier = ext-news-plugin-tag-list + title = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.tag_list.title + description = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.tag_list.description + tt_content_defValues { + CType = news_taglist + } + } + } + + show = * } \ No newline at end of file diff --git a/Documentation/Misc/Changelog/11-0-0.rst b/Documentation/Misc/Changelog/11-0-0.rst new file mode 100644 index 0000000000..cfb403396b --- /dev/null +++ b/Documentation/Misc/Changelog/11-0-0.rst @@ -0,0 +1,194 @@ +.. include:: /Includes.rst.txt + +11.0.0 - XXth XXXXXXXXX 2023 +============================ + +This is the first release of the extension that supports TYPO3 12 and 11. +This also means that the **active** support for TYPO3 10 (EXT:news v9) has been stopped. + + +.. only:: html + + .. contents:: + :local: + :depth: 3 + +Breaking changes +----------------- +Even though a new major version has been released, there is only one important change which has a couple of various consequences: + +Split plugins into separate plugins +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +With the removal of the so called "SwitchableControllerActions" in TYPO3 12, the plugin of EXT:news has been splitted into separate plugins. +This means that every selection in the former flexform field "*What to display*" is now a separate plugin. + +An updated wizard in the Install Tool is available to migrate the plugins to the new plugins. + +Permission configuration +^^^^^^^^^^^^^^^^^^^^^^^^ +Due to the plugin splitting, the access permissions must be adopted as not only the plugin `news_pi1` must be allowed but all various plugins an editor is allowed to use. + +An updated wizard in the Install Tool is available to migrate the permissions to the new plugins. + +Changed plugin registration +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of using the field `CType` with `list` and `list_type` with `news_pi1, only the field `CType` is now used: + +- `news_pi1`: article list view + detail view +- `news_newsliststicky`: article list view with doesn't switch to a detail view +- `news_newsdetail`: article detail view +- `news_newsselectedlist`: selected list of articles +- `news_newsdatemenu`: date menu of articles +- `news_newssearchform`: search form +- `news_newssearchresult`: search result +- `news_categorylist`: category listing +- `news_taglist`: tag listing + +Please adopt your code if you e.g. select plugins based on the `CType` or if modify the TCA of the plugin element. + + +Features +-------- + +Optional namespaces for plugins +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As a result, the plugins can now also be configured more independently from each other by using the **optional** custom namespaces: + +.. code-block:: typoscript + + plugin { + tx_news_newsliststicky.settings { + myCustomSetting = 1 + } + + tx_news_newsdetail.settings {} + tx_news_newsselectedlist.settings {} + tx_news_newsdatemenu.settings {} + tx_news_categorylist.settings {} + tx_news_newssearchform.settings {} + tx_news_newssearchresult.settings {} + tx_news_taglist.settings {} + } + +Support of PostgreSQL +^^^^^^^^^^^^^^^^^^^^^ +PostgreSQL is now supported as database backend. +This means that the extension can be used with PostgreSQL as well as MySQL and MariaDB. + + +All Changes +----------- +This is a list of all changes in this release: :: + + 2023-02-19 Support for php 8.2 (Commit 80145a6d by Georg Ringer) + 2023-02-19 [BUGFIX] Avoid dependency conflict with core requirements (Commit 62455558 by Stefan Bürk) + 2023-02-17 [TASK] Xclass ExtensionService of extbase (Commit 259631ff by Georg Ringer) + 2023-02-16 [TASK] Require typo3/cms-composer-installers 3.1.3 for PHP 8.2 compatibility (Commit 97c530cf by Markus Klein) + 2023-02-16 [TASK] Make php-csfixer happy (Commit 599ef39a by Georg Ringer) + 2023-01-12 [FEATURE] Support EXT:sys_reaction (Commit 34309fea by Georg Ringer) + 2023-01-11 [FEATURE] Migrate plugin permissions (Commit 6238d17b by Georg Ringer) + 2022-12-28 [DOC] Start release notes (Commit b4dbee4f by Georg Ringer) + 2022-12-14 [TASK] Simplify error handling (Commit 1651e7e5 by Georg Ringer) + 2022-12-13 [TASK] Use same namespace for all plugins (Commit ff9983f1 by Georg Ringer) + 2022-12-13 [BUGFIX] Fix call in CategoryRepository (Commit 70900efd by Georg Ringer) + 2022-11-28 [BUGFIX] Order news list by sorting is missing (Commit d256ca92 by Henrik Ziegenhain) + 2022-11-28 [BUGFIX] Order news list by sorting is missing (Commit 175662c5 by Henrik Ziegenhain) + 2022-11-24 Merge remote-tracking branch 'origin/main' into 11-12 (Commit 8bb71c5a by Georg Ringer) + 2022-11-24 [BUGFIX] Order news list by sorting is missing (Commit a2348223 by Henrik Ziegenhain) + 2022-11-22 [TASK] Show count of plugins to be updated (Commit c4e2f60b by Georg Ringer) + 2022-11-22 [FEATURE] Updater for plugins (Commit 7f8b6f30 by Georg Ringer) + 2022-11-20 [BUGFIX] Fix datemenu label (Commit 7751c5e2 by Georg Ringer) + 2022-11-15 [TASK] Force 11.5.19 to avoid regression of 11.5.18 (Commit f52b8468 by Georg Ringer) + 2022-11-14 [TASK] Improve wording of plugin selection (Commit 99766863 by Georg Ringer) + 2022-11-14 [BUGFIX] Make datemenu work (Commit 4d5c0450 by Georg Ringer) + 2022-11-12 [TASK] Enable postgres functional testing in GitHub Action workflow (Commit ade6337b by Stefan Bürk) + 2022-11-11 [!!!][TASK] Remove not needed FlexformHook (Commit a5c59a26 by Georg Ringer) + 2022-11-10 [TASK] Set minimum version to 11.5.18 (Commit af0fffb5 by Georg Ringer) + 2022-11-10 [TASK] Add .php-cs-fixer.cache to gitignore (Commit cb6743a0 by Georg Ringer) + 2022-11-10 [TASK] Improve csfixer (Commit d5a91e33 by Georg Ringer) + 2022-11-10 [TASK] Make cgl happy (Commit bab2890a by Georg Ringer) + 2022-11-09 [TASK] Support postgres (Commit 635c0c94 by Georg Ringer) + 2022-11-04 [TASK] Ensure unique docker-compose name for runTests.sh execution (Commit 0ae07522 by Stefan Bürk) + 2022-11-04 [TASK] Add unit tests execution to GitHub Action workflows (Commit b0798263 by Stefan Bürk) + 2022-11-03 [TASK] Ensure code files follows cgl rules (Commit 8fe9ed21 by Stefan Bürk) + 2022-11-03 [TASK] Implement coding-style guideline guard (Commit ff376ae7 by Stefan Bürk) + 2022-11-03 [BUGFIX] Fix update wizard DB queries (Commit 4e6ef7ab by Georg Ringer) + 2022-11-03 [BUGFIX] Remove unused class (Commit 91d387be by Georg Ringer) + 2022-11-03 [TASK] Ignore more false positives of extension scanner (Commit f5f5e56b by Georg Ringer) + 2022-11-01 Apply fixes from StyleCI (Commit 9327a28e by StyleCI Bot) + 2022-11-01 [TASK] Introduce Build/Scripts/runTests.sh as testing wrapper (Commit c096f4b3 by Stefan Bürk) + 2022-11-01 [BUGFIX] Avoid PHP8.1 error if null is passed for int method argument (Commit 4cf87d59 by Stefan Bürk) + 2022-11-01 [BUGFIX] Avoid incorrect TCA language type configuration (Commit 7e36261a by Stefan Bürk) + 2022-11-01 [TASK] Remove old "ci" workflow (Commit f8a9cfb1 by Stefan Bürk) + 2022-11-01 [TASK] Avoid dependency as non-dev and dev dependency (Commit d00217ba by Stefan Bürk) + 2022-11-01 [BUGFIX] Avoid `Cannot unpack array with string keys` error (Commit 614811f1 by Stefan Bürk) + 2022-11-01 [TASK] Avoid prophecy in skipped TagControllerTest (Commit 888a23df by Stefan Bürk) + 2022-11-01 [TASK] Move php-cs-fixer configuration (Commit 404e6b38 by Stefan Bürk) + 2022-11-01 [TASK] Add typo3/testing-framework as dev dependency (Commit a4597ba1 by Stefan Bürk) + 2022-11-01 [TASK] Remove unused dev dependency `php-coveralls` (Commit f179cbf0 by Stefan Bürk) + 2022-11-01 [TASK] Add .idea and .fleet folders to .gitignore (Commit 455b52df by Stefan Bürk) + 2022-11-01 [TASK] Remove wildly distributed duplicates of tests configs (Commit 2050d267 by Stefan Bürk) + 2022-11-01 [TASK] Disable GitHub Action workflow jobs (Commit 7523183e by Stefan Bürk) + 2022-10-29 [TASK] Use ContextualFeedbackSeverity::INFO if available (Commit f95d0a30 by Georg Ringer) + 2022-10-29 [!!!][TASK] Remove the import controller (Commit be192a72 by Georg Ringer) + 2022-10-29 [TASK] Remove usage of objectmanager (Commit 69f7ddce by Georg Ringer) + 2022-10-29 [TASK] Remove outdated usage of ::getInstance (Commit f095a50f by Georg Ringer) + 2022-10-29 [TASK] Skip false positives in extension scanner (Commit 3216cf4f by Georg Ringer) + 2022-10-29 [BUGFIX] Fix test (Commit eb10333c by Georg Ringer) + 2022-10-29 [BUGFIX] Force editlink to be a string (Commit 2128ee75 by Georg Ringer) + 2022-10-29 [TASK] Migrate to withFormat (Commit 6497cf5f by Georg Ringer) + 2022-10-29 [TASK] Simplify code in LinkViewHelper (Commit e2312f7e by Georg Ringer) + 2022-10-29 [TASK] Proper initilization of RendererRegistry (Commit dcd6b70a by Georg Ringer) + 2022-10-29 [TASK] Let extension scanner skip implementation of QueryGenerator (Commit 10ce1b97 by Georg Ringer) + 2022-10-29 [TASK] Remove usage of TYPO3_mode from Utility\Page (Commit 99df8a6c by Georg Ringer) + 2022-10-29 [TASK] Migrate ExtensionManagementUtility::allowTableOnStandardPages (Commit 3eb33fd9 by Georg Ringer) + 2022-10-29 [TASK] Let extension scanner skip handled issues in SearchFormViewHelper (Commit 33ca5f9d by Georg Ringer) + 2022-10-29 [!!!][TASK] The ViewHelper IncludeFileViewHelper has been removed (Commit 29285166 by Georg Ringer) + 2022-10-29 [TASK] Use own implementation of GeneralUtility::rmFromList (Commit 9e88753d by Georg Ringer) + 2022-10-29 [TASK] Use own implementation of the QueryGenerator (Commit ccbd8360 by Georg Ringer) + 2022-10-29 [TASK] Remove non needed typo3_mode call (Commit 11523181 by Georg Ringer) + 2022-10-29 [TASK] let extension scanner skip a class (Commit 26c8ee15 by Georg Ringer) + 2022-10-29 [TASK] Migrate to forwardResponse (Commit 99b05012 by Georg Ringer) + 2022-10-29 [TASK] Replace calls to orX & andX (Commit 66ba7377 by Georg Ringer) + 2022-10-29 [TASK] Let extension scanner skip fixed deprecated usage (Commit 1510ed74 by Georg Ringer) + 2022-10-29 [TASK] Replace hook modifyQuery for pagemodule (Commit bd4675d1 by Georg Ringer) + 2022-10-29 [TASK] Skip CSH for 12+ (Commit c5c50d45 by Georg Ringer) + 2022-10-29 [TASK] Replace usage of tceformsInlineHook (Commit 8a2691ef by Georg Ringer) + 2022-10-29 [!!!] Remove contentElementPreview (Commit 7c775efe by Georg Ringer) + 2022-10-29 [BUGFIX] Use correct error response (Commit bbee02d1 by Georg Ringer) + 2022-10-29 [TASK] Change preview rendering (Commit dc697be9 by Georg Ringer) + 2022-10-29 [TASK] Unify icon names (Commit 2b8376e7 by Georg Ringer) + 2022-10-28 [TASK] Followup, allow it as plugin.. (Commit 0daa22cf by Georg Ringer) + 2022-10-28 [TASK] Require sbuerk/typo3-cmscomposerinstallers-testingframework-bridge (Commit ab8c8875 by Georg Ringer) + 2022-10-28 [TASK] Allow 12 in tests (Commit 93bba8cc by Georg Ringer) + 2022-10-28 [TASK] Raise testing framework (Commit 4d3a2cf6 by Georg Ringer) + 2022-10-28 [BUGFIX] Update queries (Commit 700d2b22 by Georg Ringer) + 2022-10-28 [TASK] Migrate ExtensionManagementUtility::getFileFieldTCAConfig (Commit d5998e15 by Georg Ringer) + 2022-10-28 [TASK] Migrate TCA (Commit 96a7fbed by Georg Ringer) + 2022-10-28 [BUGFIX] Fix typo in fixture (Commit 81a542ee by Georg Ringer) + 2022-10-28 [TASK] Update queries + unit tests (Commit 8c73c1bb by Georg Ringer) + 2022-10-28 [BUGFIX] Fix icons (Commit 0291fc73 by Georg Ringer) + 2022-10-28 [TASK] Add invidiual icons for content elements (#1893) (Commit c6d55178 by Malte Riechmann) + 2022-10-26 [TASK] Migrate DB call (Commit 928dcba7 by Georg Ringer) + 2022-10-26 [TASK] Migrate missing controller pieces (Commit 35d8301e by Georg Ringer) + 2022-10-26 [TASK] 1st cleanup of FlexformHook (Commit b2721f93 by Georg Ringer) + 2022-10-26 [TASK] Update flexforms (Commit 85ac6ff7 by Georg Ringer) + 2022-10-26 Apply fixes from StyleCI (#1894) (Commit 4c885f6a by Georg Ringer) + 2022-10-25 [TASK] Move test base to csv (Commit c7603d23 by Georg Ringer) + 2022-10-25 [!!!][WIP][FEATURE] Switch to plugins instead of switchable controller actions" (Commit 2a3eda69 by Georg Ringer) + 2022-10-12 [TASK] Avoid usage of objectmanager (Commit 8a086688 by Georg Ringer) + 2022-10-12 [TASK] Switch to proper response in actions (Commit fb367c3e by Georg Ringer) + 2022-10-12 [TASK] Remove leftover of tca (Commit 8b3e2772 by Georg Ringer) + 2022-10-12 [TASK] Use other variable name for icons (Commit 4ea14028 by Georg Ringer) + 2022-10-12 [TASK] Remove t3ver_ fields from ext_tables.sql (Commit 01b540c8 by Georg Ringer) + 2022-10-12 [TASK] Remove tca showRemovedLocalizationRecords option (Commit c31ad45c by Georg Ringer) + 2022-10-12 [TASK] Remove ctrl|thumbnail usage (Commit 846970f5 by Georg Ringer) + 2022-10-12 [TASK] Convert tca sys_language_uid (Commit a566f9e0 by Georg Ringer) + 2022-10-12 [TASK] Remove not needed check (Commit 791969b5 by Georg Ringer) + 2022-10-12 [TASK] Set correct version constraints (Commit 8cdf6b7d by Georg Ringer) + 2022-10-12 [TASK] Rename mode (Commit ab66a58b by Georg Ringer) + 2022-10-12 [TASK] Move icons (Commit e2532645 by Georg Ringer) + +This list has been created by using `git log $(git describe --tags --abbrev=0)..HEAD --abbrev-commit --pretty='%ad %s (Commit %h by %an)' --date=short`. diff --git a/Documentation/Misc/Changelog/Index.rst b/Documentation/Misc/Changelog/Index.rst index f7b07c100f..521c0ad74b 100644 --- a/Documentation/Misc/Changelog/Index.rst +++ b/Documentation/Misc/Changelog/Index.rst @@ -19,6 +19,7 @@ List of versions :titlesonly: :glob: + 11-0-0 10-0-3 10-0-2 10-0-1 diff --git a/Documentation/Reference/ExtensionConfiguration/Index.rst b/Documentation/Reference/ExtensionConfiguration/Index.rst index 3c8efd0eb0..ef4a75aeb8 100644 --- a/Documentation/Reference/ExtensionConfiguration/Index.rst +++ b/Documentation/Reference/ExtensionConfiguration/Index.rst @@ -138,19 +138,6 @@ Use content element relation `contentElementRelation` More information can be found at http://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEform/Index.html. - -.. _extensionConfigurationContentElementPreview: - -Improved preview of content element relations `contentElementPreview` ---------------------------------------------------------------------- - -.. confval:: contentElementPreview - - :type: bool - :Default: 1 - - If set, the preview in the backend is rendered as in the page module. - .. _extensionConfigurationManualSorting: Enable manual sorting of news records `manualSorting` @@ -245,8 +232,6 @@ Show administration module `showAdministrationModule` If set, the backend module "News" is shown. This view might be easier for editors who use a very limited set of features in the backend. -.. _extensionConfigurationShowImporter: - .. _extensionConfigurationHidePageTreeForAdministrationModule: Hide page tree for Administration module `hidePageTreeForAdministrationModule` @@ -262,22 +247,6 @@ Hide page tree for Administration module `hidePageTreeForAdministrationModule` achieve a very simple workflow for editors if those need only to create news records. -Import Module -============= - -Show importer `showImporter` ----------------------------- - -.. confval:: showImporter - - :type: bool - :Default: 0 - - If set, the backend module "News import" is shown. This is used to - import news articles from sources like t3blog, tt_news or custom providers. - -.. _extensionConfigurationStorageUidImporter: - UID of storage to use when importing files/images `storageUidImporter` ---------------------------------------------------------------------- @@ -311,18 +280,20 @@ you want to include the setting in version control. .. code-block:: php :caption: AdditionalConfiguration.php - $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['news'] = serialize([ - 'archiveDate' => 'date', - 'rteForTeaser' => 0, - 'tagPid' => 1, - 'prependAtCopy' => 0, - 'categoryRestriction' => 'none', - 'categoryBeGroupTceFormsRestriction' => 0, - 'contentElementRelation' => 1, - 'manualSorting' => 0, - 'dateTimeNotRequired' => 0, - 'showAdministrationModule' => 1, - 'showImporter' => 0, - 'storageUidImporter' => '1', - 'resourceFolderImporter' => '/news_import', - ]), + $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['news'] = [ + 'advancedMediaPreview' => '1', + 'archiveDate' => 'date', + 'categoryBeGroupTceFormsRestriction' => '0', + 'categoryRestriction' => 'none', + 'contentElementRelation' => '1', + 'dateTimeNotRequired' => '0', + 'hidePageTreeForAdministrationModule' => '0', + 'manualSorting' => '0', + 'prependAtCopy' => '1', + 'resourceFolderImporter' => '/news_import', + 'rteForTeaser' => '0', + 'showAdministrationModule' => '1', + 'slugBehaviour' => 'unique', + 'storageUidImporter' => '1', + 'tagPid' => '1', + ]; diff --git a/Documentation/Reference/ViewHelpers/IncludeFileViewHelper.rst b/Documentation/Reference/ViewHelpers/IncludeFileViewHelper.rst deleted file mode 100644 index e26ebb51c7..0000000000 --- a/Documentation/Reference/ViewHelpers/IncludeFileViewHelper.rst +++ /dev/null @@ -1,56 +0,0 @@ -IncludeFileViewHelper --------------------------- - -ViewHelper to include a css/js file - -**Type:** Basic - - -General properties -^^^^^^^^^^^^^^^^^^^^^^^ - -.. t3-field-list-table:: - :header-rows: 1 - - - :Name: Name: - :Type: Type: - :Description: Description: - :Default value: Default value: - - - :Name: - compress - :Type: - boolean - :Description: - Define if file should be compressed - :Default value: - - - - :Name: - \* path - :Type: - string - :Description: - Path to the CSS/JS file which should be included - :Default value: - - - - -Examples -^^^^^^^^^^^^^ - -Basic example -"""""""""""""""""" - - - -Code: :: - - - - -Output: :: - - This will include the file provided by {settings} in the header - diff --git a/Documentation/Reference/ViewHelpers/Index.rst b/Documentation/Reference/ViewHelpers/Index.rst index 7e29034dad..a6d02269e6 100644 --- a/Documentation/Reference/ViewHelpers/Index.rst +++ b/Documentation/Reference/ViewHelpers/Index.rst @@ -33,7 +33,6 @@ All ViewHelpers ExcludeDisplayedNewsViewHelper HeaderDataViewHelper - IncludeFileViewHelper LinkViewHelper MediaFactoryViewHelper MetaTagViewHelper diff --git a/Documentation/Tutorials/ExtendNews/AddCustomType/Index.rst b/Documentation/Tutorials/ExtendNews/AddCustomType/Index.rst index 3e6ab18a2c..6ab1c7bf65 100644 --- a/Documentation/Tutorials/ExtendNews/AddCustomType/Index.rst +++ b/Documentation/Tutorials/ExtendNews/AddCustomType/Index.rst @@ -46,7 +46,7 @@ Therefore, create the file `Configuration/TCA/Overrides/tx_news_domain_model_new .. code-block:: php action", value is label - $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['newItems']['News->byFobar'] = 'A fobar action'; - -Remove fields in additional actions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If you define an additional action, you won't need all available fields which are available inside the FlexForms. If you want to hide some fields, -take a look at the hook inside the class Hooks/BackendUtility.php: - -.. code-block:: php - - $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Hooks/BackendUtility.php']['updateFlexforms'] - Additional Template Selector ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you need a kind of template selector inside a plugin, you can add diff --git a/Documentation/Tutorials/ExtendNews/ExtensionBasedOnNews/Index.rst b/Documentation/Tutorials/ExtendNews/ExtensionBasedOnNews/Index.rst index d63fcbb067..2f4174646e 100644 --- a/Documentation/Tutorials/ExtendNews/ExtensionBasedOnNews/Index.rst +++ b/Documentation/Tutorials/ExtendNews/ExtensionBasedOnNews/Index.rst @@ -64,7 +64,7 @@ Create a basic plugin with one action called ``list``. .. code-block:: php objectManager->get(NewsDemand::class); + $demand = new NewsDemand(); $demand->setLimit(10); return $demand; @@ -203,7 +203,7 @@ By modifying the controller with the following code, you will change the output */ protected function createDemandObject() { - $demand = $this->objectManager->get(NewsDemand::class); + $demand = new NewsDemand(); $demand->setStoragePage('123'); $demand->setAuthor('John'); $demand->setHideIdList('12,45'); @@ -224,7 +224,7 @@ Exchange the existing file with the following content. .. code-block:: php objectManager->get(NewsDemand::class); + $demand = new NewsDemand(); // Because of the naming "", you can use $this->settings['startingpoint'] $demand->setStoragePage($this->settings['startingpoint']); $demand->setLimit(10); diff --git a/Documentation/Tutorials/ExtendNews/Hooks/Index.rst b/Documentation/Tutorials/ExtendNews/Hooks/Index.rst index ee7aff1a35..a8fa39388b 100644 --- a/Documentation/Tutorials/ExtendNews/Hooks/Index.rst +++ b/Documentation/Tutorials/ExtendNews/Hooks/Index.rst @@ -34,7 +34,7 @@ First, register your implementation in the file ``ext_localconf.php``: .. code-block:: php modify'; @@ -83,7 +83,7 @@ First, register your implementation in the file ``ext_localconf.php``: .. code-block:: php modify'; diff --git a/Documentation/Tutorials/ExtendNews/ProxyClassGenerator/Index.rst b/Documentation/Tutorials/ExtendNews/ProxyClassGenerator/Index.rst index 72d242bcd0..fd6d00397e 100644 --- a/Documentation/Tutorials/ExtendNews/ProxyClassGenerator/Index.rst +++ b/Documentation/Tutorials/ExtendNews/ProxyClassGenerator/Index.rst @@ -94,7 +94,7 @@ Therefore, create the file :file:`Configuration/TCA/Overrides/tx_news_domain_mod .. code-block:: php array( @@ -131,7 +131,7 @@ Create the file :file:`ext_localconf.php` in the root of the extension: .. code-block:: php >>>>>> origin/main [Contribute](https://docs.typo3.org/p/georgringer/news/main/en-us/Introduction/Contribution/Index.html) to this project to let your skills flow into its present and future architecture. diff --git a/Resources/Private/Language/locallang_be.xlf b/Resources/Private/Language/locallang_be.xlf index 4984f11340..5055150549 100644 --- a/Resources/Private/Language/locallang_be.xlf +++ b/Resources/Private/Language/locallang_be.xlf @@ -1,453 +1,509 @@ - -
- - + +
+ + News system - + Versatile news system - + + List articles with detail view + + + Display of articles chosen by various optional properties like storage page, categories,... + Plugin is capable of displaying the detail view as well. + + + Sticky article list view + + + Display of articles chosen by various optional properties like storage page, categories,... + + + Article detail view + + + Display the detail view of an article + + + Date menu of articles + + + Display a menu of months & years of articles. The menu can be used to filter a list view dynamically. + + + Search form + + + Display a search form to let users search within articles + + + Search result + + + Display the result of the search + + + Selected list of articles + + + Display a manually picked list of articles. + + + Category menu + + + Display a menu of categories. The menu can be used to filter a list view dynamically. + + + Tag list + + + Display a list of tags. The list can be used to filter a list view dynamically. + + + Settings - + Additional - + Template - + What to display - + List view - + List view (without overloading detail view) - + Detail view - + Search form - + Search result - + Date menu - + List of selected items - + Category Menu - + No view yet configured - + Search - + Others - + Tag list - + Archive - + Only active (non archived) - + Archived - + Sort by - + Uid - + Manual sorting - + Last edited - + Created - + Given date/time - + Title - + Sort direction - + Ascending - + Descending - + Date field to use - + Given date/time - + Archive date - + Category selection - + Category mode - + Don't care, show all - + Show items with selected categories (OR) - + Show items with selected categories (AND) - + Do NOT show items with selected categories (AND) - + Do NOT show items with selected categories (OR) - + Include subcategories - + Article date higher than: - + Article date lower than: - + Top News - + only Top News records - + except Top News records - + Show a single news record - + Allow preview of hidden records - + No - + Yes - + Defined in TypoScript - + Defined in TypoScript - + [no constraint] - + List of articles - + Max width for media elements - + Max height for media elements - + Length of teaser (in chars) - + Template Layout - + 1 - + 2 - + PageId for single news display - + PageId to return to - + PageId for list display - + Max records displayed - + Starting with given news record. 0 means first record, 1 the 2nd one! - + Hide the pagination - + Items per Page - + Sort "Top news" before - + Disable override demand - + Exclude already displayed news - + Tags - + Page with uid "%s" is not available anymore! - + Record with uid "%s" is not available anymore! - + News record with uid "%s" is not available anymore! - + Switch to this page - + Simple list - + Advanced list - + Full list - + Prepend at copy: Prepend string "copy X". - + Category restriction: Restrict the available categories in news records. PageTsConfig: TCEFORM.tx_news_domain_model_news.categories.PAGE_TSCONFIG_IDLIST=120. This feature is currently under development and not beeing expected to work! - + Categories from current page - + Categories from site root - + Page TsConfig - + No restriction - + Editor needs to have permissions to all selected categories to save a news item - + Enable manual sorting of news records - + Use content element relation:If set, content elements can be added to news records. - + Improved preview of content element relations:If set, the preview in the backend is rendered as in the page module. - + Define pid of tag records:Tags are collected on one central page. - + Archive Date: Define if the archive date is a "Date" or "Date & Time" - + Date - + Date & Time - + Show importer:Backend module to import into news - + UID of storage to use when importing files/images:Default (fileadmin) storage is 1 - + In which folder should the importer save files/images (has to exist) - + Show administration module:Backend module to administrate news records - + Enable a RTE for the teaser field. - + Disable required date field:If set, the date field is not required and not filled automatically when creating a new record. - + Hide page tree for Administration module: To simplify the usability, hide the page tree for the administration module. - + Show thumbnails in backend list module: If enabled, the list module will show thumbnails of the media items. - + Advanced preview configuration for media files: If enabled, more options are available for editors defining where an media element should be displayed. - + Slug behaviour: uniqueInSite: The same slug can be used for news in different sites. Use this setting *only* if no news records are shared between sites. "unique" means that same news title will lead to different slug names. - + Use this overlay for news categories in the Backend - + There are no languages available, so nothing to choose. - + Start import with %s record(s). - + Tag "%s" could not be found, wanna create it? <strong>Click here</strong> - + Tag could not be found, wanna create it? Click here! - + No tag submitted! - + No news id given! - + No pid for the tag record could be found by reading settings of Extension Manager! - + No new tag created! - + No page defined to save tag. Please add the id in the settings of the extension manager. - + Settings - + Recursive - + Time range - + Time Restriction - + Time Restriction High - + Create a new category - + Create new news record - + Create new tag record - + Yes - + No - + Search - + News Listing - + %s news records - + News Pid listing - + Support & Donate - + News administration - + Please click the page title in the page tree to the left to show the records on that page. - + List pages with count of news & category records - + Choose a recursive level to display your page tree with the related entries. Click on the page title to show the news entries of the page. - + No limit defined in setting "%s"! Include the default TypoScript in the root page. - + Show/Hide filter - + No news found - + The current page does not contain any news records. Either select another page in the page tree on the left or create the first news record on this page. - + See all pages containing news records - + Hidden - + only hidden - + only non-hidden - + Support & Donate - + Click so see all options - + Great that you are using this extension! - + The editors have created %d articles with %d relations to categories. - + The editors have created %d articles. - + Did you just setup the system? No articles yet created. - + Help supporting further development - + Why? @@ -482,74 +538,75 @@ Support me by a donation on paypal.com. It is just one click away. - + Amazon wishlist Satisfy a wish of my Amazon wishlist - + Most of the listed products are for my family and our hobby cooking. Make us happy! Current sponsors - + The following companies and people have already supported me. - + News - + Page with news plugins - + News Importer - + Choose a job - + This is the "News importer module". - + The import has been completed. Reload the module to start a new one. - + It's strongly recommended to backup all news tables before running an import job. - + Important! - + No jobs available for the importer. - + The configuration for the import is incomplete! - + Please define the setting "resourceFolderImporter" in the configuration of the extension manager! The given directory will contain all imported files. - + The directory defined in the setting "resourceFolderImporter" does not exist! - + Please define the setting "storageUidImporter" in the configuration of the extension manager! The given id is the used file storage. - - Saving is disabled - - - This record has the following categories assigned that are not defined in your permissions: - - - Content elements are hidden - - - Content elements are hidden in sys folders of type "news"! - - - + + Saving is disabled + + + This record has the following categories assigned that are not defined in your permissions: + + + + Content elements are hidden + + + Content elements are hidden in sys folders of type "news"! + + + diff --git a/Resources/Private/Layouts/Detail.html b/Resources/Private/Layouts/Detail.html index 39b5f16cbc..9d2e81101e 100644 --- a/Resources/Private/Layouts/Detail.html +++ b/Resources/Private/Layouts/Detail.html @@ -3,7 +3,7 @@ data-namespace-typo3-fluid="true"> - +
diff --git a/Resources/Private/Layouts/General.html b/Resources/Private/Layouts/General.html index de6c2a834c..990c675db7 100644 --- a/Resources/Private/Layouts/General.html +++ b/Resources/Private/Layouts/General.html @@ -3,7 +3,7 @@ data-namespace-typo3-fluid="true"> - +
diff --git a/Resources/Public/Icons/module_import.svg b/Resources/Public/Icons/module_import.svg deleted file mode 100644 index 8a5fd1c027..0000000000 --- a/Resources/Public/Icons/module_import.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Resources/Public/Icons/plugin-category-menu.svg b/Resources/Public/Icons/plugin-category-menu.svg new file mode 100755 index 0000000000..f01e46c906 --- /dev/null +++ b/Resources/Public/Icons/plugin-category-menu.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-date-menu.svg b/Resources/Public/Icons/plugin-date-menu.svg new file mode 100755 index 0000000000..a879f113ec --- /dev/null +++ b/Resources/Public/Icons/plugin-date-menu.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-detail.svg b/Resources/Public/Icons/plugin-detail.svg new file mode 100755 index 0000000000..e4af98b671 --- /dev/null +++ b/Resources/Public/Icons/plugin-detail.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-list-with-detail.svg b/Resources/Public/Icons/plugin-list-with-detail.svg new file mode 100755 index 0000000000..3a294e3888 --- /dev/null +++ b/Resources/Public/Icons/plugin-list-with-detail.svg @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-list.svg b/Resources/Public/Icons/plugin-list.svg new file mode 100755 index 0000000000..c31e717d58 --- /dev/null +++ b/Resources/Public/Icons/plugin-list.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-search-form.svg b/Resources/Public/Icons/plugin-search-form.svg new file mode 100755 index 0000000000..23709479b2 --- /dev/null +++ b/Resources/Public/Icons/plugin-search-form.svg @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-search-results.svg b/Resources/Public/Icons/plugin-search-results.svg new file mode 100755 index 0000000000..1e58829562 --- /dev/null +++ b/Resources/Public/Icons/plugin-search-results.svg @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-selected-list.svg b/Resources/Public/Icons/plugin-selected-list.svg new file mode 100755 index 0000000000..f20dc31f9d --- /dev/null +++ b/Resources/Public/Icons/plugin-selected-list.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + diff --git a/Resources/Public/Icons/plugin-tag-menu.svg b/Resources/Public/Icons/plugin-tag-menu.svg new file mode 100755 index 0000000000..ee127a34c4 --- /dev/null +++ b/Resources/Public/Icons/plugin-tag-menu.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + diff --git a/Resources/Public/Icons/plugin_wizard.svg b/Resources/Public/Icons/plugin_wizard.svg deleted file mode 100644 index 9dc293823e..0000000000 --- a/Resources/Public/Icons/plugin_wizard.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Tests/Build/FunctionalTests.xml b/Tests/Build/FunctionalTests.xml deleted file mode 100644 index 252703cb0b..0000000000 --- a/Tests/Build/FunctionalTests.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - ../Functional/ - - - diff --git a/Tests/Build/UnitTests.xml b/Tests/Build/UnitTests.xml deleted file mode 100644 index 84751dbefb..0000000000 --- a/Tests/Build/UnitTests.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - ../Unit/ - - - - - diff --git a/Tests/Functional/Controller/NewsControllerTest.php b/Tests/Functional/Controller/NewsControllerTest.php deleted file mode 100644 index 945d972e9e..0000000000 --- a/Tests/Functional/Controller/NewsControllerTest.php +++ /dev/null @@ -1,161 +0,0 @@ -importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); - $this->setUpFrontendRootPage( - 1, - [ - __DIR__ . '/../Fixtures/TypoScript/setup.typoscript' - ] - ); - - // This part is needed for TYPO3 10 compatibility - /** @var EnvironmentService|ObjectProphecy $environmentServiceProphecy */ - $environmentServiceProphecy = $this->prophesize(EnvironmentService::class); - $environmentServiceProphecy - ->isEnvironmentInFrontendMode() - ->willReturn(true); - $environmentServiceProphecy - ->isEnvironmentInBackendMode() - ->willReturn(false); - GeneralUtility::setSingletonInstance(EnvironmentService::class, $environmentServiceProphecy->reveal()); - - $serverRequest = new ServerRequest(); - - $applicationType = SystemEnvironmentBuilder::REQUESTTYPE_FE; - $serverRequest = $serverRequest->withAttribute('applicationType', $applicationType); - - /** @var TypoScriptFrontendController|ObjectProphecy $typoScriptFrontendControllerProphecy */ - $typoScriptFrontendControllerProphecy = $this->prophesize(TypoScriptFrontendController::class); - /** @var FrontendUserAuthentication|ObjectProphecy $frontendUserAuthenticationProphecy */ - $frontendUserAuthenticationProphecy = $this->prophesize(FrontendUserAuthentication::class); - - $GLOBALS['TYPO3_REQUEST'] = $serverRequest; - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); - $GLOBALS['TSFE'] = $typoScriptFrontendControllerProphecy->reveal(); - $GLOBALS['TSFE']->fe_user = $frontendUserAuthenticationProphecy->reveal(); - } - - protected function tearDown(): void - { - unset( - $this->subject - ); - - parent::tearDown(); - } - - /** - * @test - */ - public function listActionWillReturnNoNews(): void - { - $extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class); - $content = $extbaseBootstrap->run( - '', - [ - 'extensionName' => 'News', - 'pluginName' => 'Pi1' - ] - ); - - $this->assertStringContainsString( - 'No news available.', - $content - ); - } - - /** - * @test - */ - public function listActionWillShowNewsOfStoragePage1(): void - { - $date = new \DateTime('now'); - - $connection = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tx_news_domain_model_news'); - $connection->insert( - 'tx_news_domain_model_news', - [ - 'uid' => 1, - 'pid' => 1, - 'title' => 'My first news', - 'datetime' => (int)$date->format('U') - ] - ); - - $extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class); - $content = $extbaseBootstrap->run( - '', - [ - 'extensionName' => 'News', - 'pluginName' => 'Pi1' - ] - ); - - $this->assertStringContainsString( - 'My first news', - $content - ); - - $this->assertStringContainsString( - '
'; - $this->assertEquals(trim($expected), trim($standaloneView->render())); + self::assertEquals(trim($expected), trim($standaloneView->render())); } } diff --git a/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php b/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php index 1fe3c15c08..91ce89153e 100644 --- a/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php @@ -1,14 +1,14 @@ news->_setProperty('uid', 123); $this->news->setPid(9); - $this->importDataSet(__DIR__ . '/../Fixtures/tx_news_domain_model_news.xml'); + $this->importCSVDataSet(__DIR__ . '/../Fixtures/tx_news_domain_model_news.csv'); } /** * @test - * - * @return void */ public function allNeighboursCanBeFound(): void { @@ -55,15 +52,13 @@ public function allNeighboursCanBeFound(): void $exp = [ 'prev' => $this->getRow(102), - 'next' => $this->getRow(104) + 'next' => $this->getRow(104), ]; - $this->assertEquals($exp, $actual); + self::assertEquals($exp, $actual); } /** * @test - * - * @return void */ public function nextNeighbourCanBeFound(): void { @@ -72,30 +67,26 @@ public function nextNeighbourCanBeFound(): void $actual = $this->mockedViewHelper->_call('getNeighbours', $this->news, '', 'datetime'); $exp = [ - 'next' => $this->getRow(102) + 'next' => $this->getRow(102), ]; - $this->assertEquals($exp, $actual); + self::assertEquals($exp, $actual); } /** * @test - * - * @return void */ public function previousNeighbourCanBeFound(): void { $this->setDate(1396640035); $actual = $this->mockedViewHelper->_call('getNeighbours', $this->news, '', 'datetime'); $exp = [ - 'prev' => $this->getRow(105) + 'prev' => $this->getRow(105), ]; - $this->assertEquals($exp, $actual); + self::assertEquals($exp, $actual); } /** * @param int $timestamp - * - * @return void */ protected function setDate($timestamp): void { @@ -118,6 +109,6 @@ protected function getRow(int $id) $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)) ) ->setMaxResults(1) - ->execute()->fetch(); + ->executeQuery()->fetchAssociative(); } } diff --git a/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php b/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php index 1a28af6702..783e4c567b 100644 --- a/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php +++ b/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php @@ -1,14 +1,14 @@ getAccessibleMock(NewsRowInitializeNew::class, ['dummy'], [], '', false); $mockedEmConfiguration = $this->getAccessibleMock(EmConfiguration::class, ['getDateTimeRequired'], [], '', false); - $mockedEmConfiguration->expects($this->once())->method('getDateTimeRequired')->will($this->returnValue(true)); + $mockedEmConfiguration->expects(self::once())->method('getDateTimeRequired')->willReturn(true); $provider->_set('emConfiguration', $mockedEmConfiguration); @@ -32,24 +30,22 @@ public function dateTimeIsFilled(): void $result = [ 'command' => 'new', - 'tableName' => 'tx_news_domain_model_news' + 'tableName' => 'tx_news_domain_model_news', ]; $expected = [ 'command' => 'new', 'tableName' => 'tx_news_domain_model_news', 'databaseRow' => [ - 'datetime' => $GLOBALS['EXEC_TIME'] - ] + 'datetime' => $GLOBALS['EXEC_TIME'], + ], ]; - $this->assertEquals($expected, $provider->addData($result)); + self::assertEquals($expected, $provider->addData($result)); } /** * @test - * - * @return void */ public function dateTimeIsNotFilledIfSetInExtensionManagerConfiguration(): void { @@ -60,26 +56,24 @@ public function dateTimeIsNotFilledIfSetInExtensionManagerConfiguration(): void $result = [ 'command' => 'new', - 'tableName' => 'tx_news_domain_model_news' + 'tableName' => 'tx_news_domain_model_news', ]; $expected = [ 'command' => 'new', 'tableName' => 'tx_news_domain_model_news', ]; - $this->assertEquals($expected, $mockedProvider->addData($result)); + self::assertEquals($expected, $mockedProvider->addData($result)); } /** * @test - * - * @return void */ public function archiveTimeIsFilled(): void { $provider = $this->getAccessibleMock(NewsRowInitializeNew::class, ['dummy'], [], '', false); $mockedEmConfiguration = $this->getAccessibleMock(EmConfiguration::class, ['getDateTimeRequired'], [], '', false); - $mockedEmConfiguration->expects($this->once())->method('getDateTimeRequired')->will($this->returnValue(true)); + $mockedEmConfiguration->expects(self::once())->method('getDateTimeRequired')->willReturn(true); $provider->_set('emConfiguration', $mockedEmConfiguration); @@ -91,16 +85,16 @@ public function archiveTimeIsFilled(): void 'pageTsConfig' => [ 'tx_news.' => [ 'predefine.' => [ - 'archive' => '+10 days' - ] - ] - ] + 'archive' => '+10 days', + ], + ], + ], ]; $expected = $result; $expected['databaseRow']['datetime'] = $GLOBALS['EXEC_TIME']; $expected['databaseRow']['archive'] = strtotime('+10 days'); - $this->assertEquals($expected, $provider->addData($result)); + self::assertEquals($expected, $provider->addData($result)); } } diff --git a/Tests/Unit/Controller/TagControllerTest.php b/Tests/Unit/Controller/TagControllerTest.php index 16af5ec721..23ffae0706 100644 --- a/Tests/Unit/Controller/TagControllerTest.php +++ b/Tests/Unit/Controller/TagControllerTest.php @@ -1,62 +1,49 @@ tagRepository = $this->prophesize(TagRepository::class); - } - /** - * Test for creating correct demand call - * * @test - * - * @return void + * @todo Eventually migrate this to a functional test instead, remove it or get it working again. */ public function listActionFindsDemandedTagsByDemandFromSettings(): void { - $this->markTestSkipped('May not be relevant anymore. Reason: failing because of using DI'); + self::markTestSkipped('May not be relevant anymore. Reason: failing because of using DI'); + $tagRepositoryMock = $this->getMockBuilder(TagRepository::class)->disableOriginalConstructor()->getMock(); $demand = new NewsDemand(); $settings = ['list' => 'foo', 'orderBy' => 'datetime']; - $fixture->_set('tagRepository', $this->tagRepository->reveal()); + $fixture = $this->getAccessibleMock(TagController::class); + $fixture->_set('tagRepository', $tagRepositoryMock); $fixture->setView($this->getMockBuilder(TemplateView::class)->disableOriginalConstructor()->getMock()); $fixture->_set('settings', $settings); - $fixture->expects($this->once())->method('createDemandObjectFromSettings') - ->will($this->returnValue($demand)); + $fixture->expects(self::once())->method('createDemandObjectFromSettings') + ->willReturn($demand); $this->tagRepository->findDemanded($demand)->shouldBeCalled(); $fixture->listAction(); // datetime must be removed - $this->assertEquals($fixture->_get('settings'), ['list' => 'foo']); + self::assertEquals($fixture->_get('settings'), ['list' => 'foo']); } } diff --git a/Tests/Unit/Domain/Model/CategoryTest.php b/Tests/Unit/Domain/Model/CategoryTest.php index 5a2f4b29b1..3fb56bbab3 100644 --- a/Tests/Unit/Domain/Model/CategoryTest.php +++ b/Tests/Unit/Domain/Model/CategoryTest.php @@ -1,22 +1,22 @@ assertSame( + self::assertSame( 0, $this->instance->getSorting() ); @@ -54,7 +54,7 @@ public function getSortingInitiallyReturnsZero(): void public function setSortingWithStringConvertsValueToInt(): void { $this->instance->setSorting('123'); - $this->assertSame( + self::assertSame( 123, $this->instance->getSorting() ); @@ -67,7 +67,7 @@ public function setSortingWithIntSetsSorting(): void { $value = 123; $this->instance->setSorting($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSorting() ); @@ -78,7 +78,7 @@ public function setSortingWithIntSetsSorting(): void */ public function getCrdateInitiallyReturnsNull(): void { - $this->assertNull( + self::assertNull( $this->instance->getCrdate() ); } @@ -90,7 +90,7 @@ public function setCrdateSetsCrdate(): void { $date = new \DateTime('now'); $this->instance->setCrdate($date); - $this->assertSame( + self::assertSame( $date, $this->instance->getCrdate() ); @@ -101,7 +101,7 @@ public function setCrdateSetsCrdate(): void */ public function getTstampInitiallyReturnsNull(): void { - $this->assertNull( + self::assertNull( $this->instance->getTstamp() ); } @@ -113,7 +113,7 @@ public function setTstampSetsTstamp(): void { $date = new \DateTime('now'); $this->instance->setTstamp($date); - $this->assertSame( + self::assertSame( $date, $this->instance->getTstamp() ); @@ -124,7 +124,7 @@ public function setTstampSetsTstamp(): void */ public function getStarttimeInitiallyReturnsNull(): void { - $this->assertNull( + self::assertNull( $this->instance->getStarttime() ); } @@ -136,7 +136,7 @@ public function setStarttimeSetsStarttime(): void { $date = new \DateTime('now'); $this->instance->setStarttime($date); - $this->assertSame( + self::assertSame( $date, $this->instance->getStarttime() ); @@ -147,7 +147,7 @@ public function setStarttimeSetsStarttime(): void */ public function getEndtimeInitiallyReturnsNull(): void { - $this->assertNull( + self::assertNull( $this->instance->getEndtime() ); } @@ -159,7 +159,7 @@ public function setEndtimeSetsEndtime(): void { $date = new \DateTime('now'); $this->instance->setEndtime($date); - $this->assertSame( + self::assertSame( $date, $this->instance->getEndtime() ); @@ -170,7 +170,7 @@ public function setEndtimeSetsEndtime(): void */ public function getHiddenInitiallyReturnsFalse(): void { - $this->assertFalse( + self::assertFalse( $this->instance->getHidden() ); } @@ -181,7 +181,7 @@ public function getHiddenInitiallyReturnsFalse(): void public function setHiddenWithStringSetsHidden(): void { $this->instance->setHidden('1'); - $this->assertTrue( + self::assertTrue( $this->instance->getHidden() ); } @@ -192,7 +192,7 @@ public function setHiddenWithStringSetsHidden(): void public function setHiddenWithIntSetsHidden(): void { $this->instance->setHidden(1); - $this->assertTrue( + self::assertTrue( $this->instance->getHidden() ); } @@ -203,7 +203,7 @@ public function setHiddenWithIntSetsHidden(): void public function setHiddenWithTrueSetsHidden(): void { $this->instance->setHidden(true); - $this->assertTrue( + self::assertTrue( $this->instance->getHidden() ); } @@ -214,7 +214,7 @@ public function setHiddenWithTrueSetsHidden(): void public function setHiddenWithFalseSetsHidden(): void { $this->instance->setHidden(false); - $this->assertFalse( + self::assertFalse( $this->instance->getHidden() ); } @@ -224,7 +224,7 @@ public function setHiddenWithFalseSetsHidden(): void */ public function getSysLanguageUidInitiallyReturnsZero(): void { - $this->assertSame( + self::assertSame( 0, $this->instance->getSysLanguageUid() ); @@ -236,7 +236,7 @@ public function getSysLanguageUidInitiallyReturnsZero(): void public function setSysLanguageUidWithStringConvertsToInt(): void { $this->instance->setSysLanguageUid('2'); - $this->assertSame( + self::assertSame( 2, $this->instance->getSysLanguageUid() ); @@ -249,7 +249,7 @@ public function setSysLanguageUidSetsSysLanguageUid(): void { $value = 3; $this->instance->setSysLanguageUid($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSysLanguageUid() ); @@ -260,7 +260,7 @@ public function setSysLanguageUidSetsSysLanguageUid(): void */ public function getL10nParentInitiallyReturnsZero(): void { - $this->assertSame( + self::assertSame( 0, $this->instance->getL10nParent() ); @@ -272,7 +272,7 @@ public function getL10nParentInitiallyReturnsZero(): void public function setL10nParentWithStringConvertsToInt(): void { $this->instance->setL10nParent('2'); - $this->assertSame( + self::assertSame( 2, $this->instance->getL10nParent() ); @@ -285,7 +285,7 @@ public function setL10nParentSetsL10nParent(): void { $value = 3; $this->instance->setL10nParent($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getL10nParent() ); @@ -296,7 +296,7 @@ public function setL10nParentSetsL10nParent(): void */ public function getTitleInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getTitle() ); @@ -308,7 +308,7 @@ public function getTitleInitiallyReturnsEmptyString(): void public function setTitleWithIntConvertsToSting(): void { $this->instance->setTitle(123); - $this->assertSame( + self::assertSame( '123', $this->instance->getTitle() ); @@ -321,7 +321,7 @@ public function setTitleSetsTitle(): void { $value = 'Hello'; $this->instance->setTitle($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getTitle() ); @@ -332,7 +332,7 @@ public function setTitleSetsTitle(): void */ public function getDescriptionInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getDescription() ); @@ -344,7 +344,7 @@ public function getDescriptionInitiallyReturnsEmptyString(): void public function setDescriptionWithIntConvertsToSting(): void { $this->instance->setDescription(123); - $this->assertSame( + self::assertSame( '123', $this->instance->getDescription() ); @@ -357,7 +357,7 @@ public function setDescriptionSetsDescription(): void { $value = 'Hello'; $this->instance->setDescription($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getDescription() ); @@ -368,7 +368,7 @@ public function setDescriptionSetsDescription(): void */ public function getParentcategoryInitiallyReturnsNull(): void { - $this->assertNull( + self::assertNull( $this->instance->getParentcategory() ); } @@ -381,7 +381,7 @@ public function setParentcategorySetsParentcategory(): void $value = new Category(); $value->setTitle('TYPO3'); $this->instance->setParentcategory($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getParentcategory() ); @@ -393,7 +393,7 @@ public function setParentcategorySetsParentcategory(): void public function getImagesInitiallyReturnsObjectStorage(): void { $value = new ObjectStorage(); - $this->assertEquals( + self::assertEquals( $value, $this->instance->getImages() ); @@ -406,7 +406,7 @@ public function setImagesSetsImages(): void { $value = new ObjectStorage(); $this->instance->setImages($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getImages() ); @@ -423,7 +423,7 @@ public function addImageAddsImage(): void $images->attach($fileReference); $this->instance->addImage($fileReference); - $this->assertEquals( + self::assertEquals( $images, $this->instance->getImages() ); @@ -445,7 +445,7 @@ public function removeImageRemovesImage(): void $this->instance->setImages($images); $this->instance->removeImage($fileReference); - $this->assertEquals( + self::assertEquals( $expectedImages, $this->instance->getImages() ); @@ -456,7 +456,7 @@ public function removeImageRemovesImage(): void */ public function getFirstImageInitiallyReturnsNull(): void { - $this->assertNull( + self::assertNull( $this->instance->getFirstImage() ); } @@ -478,7 +478,7 @@ public function getFirstImageReturnsFileReference(): void $this->instance->setImages($images); - $this->assertSame( + self::assertSame( $fileReference1, $this->instance->getFirstImage() ); @@ -489,7 +489,7 @@ public function getFirstImageReturnsFileReference(): void */ public function getShortcutInitiallyReturnsZero(): void { - $this->assertSame( + self::assertSame( 0, $this->instance->getShortcut() ); @@ -501,7 +501,7 @@ public function getShortcutInitiallyReturnsZero(): void public function setShortcutWithStringConvertsToInt(): void { $this->instance->setShortcut('43'); - $this->assertSame( + self::assertSame( 43, $this->instance->getShortcut() ); @@ -514,7 +514,7 @@ public function setShortcutSetsShortcut(): void { $value = 23; $this->instance->setShortcut($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getShortcut() ); @@ -525,7 +525,7 @@ public function setShortcutSetsShortcut(): void */ public function getSinglePidInitiallyReturnsZero(): void { - $this->assertSame( + self::assertSame( 0, $this->instance->getSinglePid() ); @@ -537,7 +537,7 @@ public function getSinglePidInitiallyReturnsZero(): void public function setSinglePidWithStringConvertsToInt(): void { $this->instance->setSinglePid('43'); - $this->assertSame( + self::assertSame( 43, $this->instance->getSinglePid() ); @@ -550,7 +550,7 @@ public function setSinglePidSetsSinglePid(): void { $value = 23; $this->instance->setSinglePid($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSinglePid() ); @@ -561,7 +561,7 @@ public function setSinglePidSetsSinglePid(): void */ public function getImportIdInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getImportId() ); @@ -573,7 +573,7 @@ public function getImportIdInitiallyReturnsEmptyString(): void public function setImportIdWithIntConvertsToString(): void { $this->instance->setImportId(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getImportId() ); @@ -586,7 +586,7 @@ public function setImportIdSetsImportId(): void { $value = '1324'; $this->instance->setImportId($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getImportId() ); @@ -597,7 +597,7 @@ public function setImportIdSetsImportId(): void */ public function getImportSourceInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getImportSource() ); @@ -609,7 +609,7 @@ public function getImportSourceInitiallyReturnsEmptyString(): void public function setImportSourceWithIntConvertsToString(): void { $this->instance->setImportSource(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getImportSource() ); @@ -622,7 +622,7 @@ public function setImportSourceSetsImportSource(): void { $value = '1324'; $this->instance->setImportSource($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getImportSource() ); @@ -633,7 +633,7 @@ public function setImportSourceSetsImportSource(): void */ public function getFeGroupInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getImportSource() ); @@ -645,7 +645,7 @@ public function getFeGroupInitiallyReturnsEmptyString(): void public function setFeGroupWithIntConvertsToString(): void { $this->instance->setFeGroup(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getFeGroup() ); @@ -658,7 +658,7 @@ public function setFeGroupSetsFeGroup(): void { $value = '1324'; $this->instance->setFeGroup($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getFeGroup() ); @@ -669,7 +669,7 @@ public function setFeGroupSetsFeGroup(): void */ public function getSeoTitleInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getSeoTitle() ); @@ -681,7 +681,7 @@ public function getSeoTitleInitiallyReturnsEmptyString(): void public function setSeoTitleWithIntConvertsToString(): void { $this->instance->setSeoTitle(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getSeoTitle() ); @@ -694,7 +694,7 @@ public function setSeoTitleSetsSeoTitle(): void { $value = 'TYPO3'; $this->instance->setSeoTitle($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSeoTitle() ); @@ -705,7 +705,7 @@ public function setSeoTitleSetsSeoTitle(): void */ public function getSeoDescriptionInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getSeoDescription() ); @@ -717,7 +717,7 @@ public function getSeoDescriptionInitiallyReturnsEmptyString(): void public function setSeoDescriptionWithIntConvertsToString(): void { $this->instance->setSeoDescription(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getSeoDescription() ); @@ -730,7 +730,7 @@ public function setSeoDescriptionSetsSeoDescription(): void { $value = 'TYPO3'; $this->instance->setSeoDescription($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSeoDescription() ); @@ -741,7 +741,7 @@ public function setSeoDescriptionSetsSeoDescription(): void */ public function getSeoHeadlineInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getSeoHeadline() ); @@ -753,7 +753,7 @@ public function getSeoHeadlineInitiallyReturnsEmptyString(): void public function setSeoHeadlineWithIntConvertsToString(): void { $this->instance->setSeoHeadline(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getSeoHeadline() ); @@ -766,7 +766,7 @@ public function setSeoHeadlineSetsSeoHeadline(): void { $value = 'TYPO3'; $this->instance->setSeoHeadline($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSeoHeadline() ); @@ -777,7 +777,7 @@ public function setSeoHeadlineSetsSeoHeadline(): void */ public function getSeoTextInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getSeoText() ); @@ -789,7 +789,7 @@ public function getSeoTextInitiallyReturnsEmptyString(): void public function setSeoTextWithIntConvertsToString(): void { $this->instance->setSeoText(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getSeoText() ); @@ -802,7 +802,7 @@ public function setSeoTextSetsSeoText(): void { $value = 'TYPO3'; $this->instance->setSeoText($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSeoText() ); @@ -813,7 +813,7 @@ public function setSeoTextSetsSeoText(): void */ public function getSlugInitiallyReturnsEmptyString(): void { - $this->assertSame( + self::assertSame( '', $this->instance->getSlug() ); @@ -825,7 +825,7 @@ public function getSlugInitiallyReturnsEmptyString(): void public function setSlugWithIntConvertsToString(): void { $this->instance->setSlug(24); - $this->assertSame( + self::assertSame( '24', $this->instance->getSlug() ); @@ -838,7 +838,7 @@ public function setSlugSetsSlug(): void { $value = 'TYPO3'; $this->instance->setSlug($value); - $this->assertSame( + self::assertSame( $value, $this->instance->getSlug() ); diff --git a/Tests/Unit/Domain/Model/Dto/EmConfigurationTest.php b/Tests/Unit/Domain/Model/Dto/EmConfigurationTest.php index 48eb82c23a..ad09143a04 100644 --- a/Tests/Unit/Domain/Model/Dto/EmConfigurationTest.php +++ b/Tests/Unit/Domain/Model/Dto/EmConfigurationTest.php @@ -1,20 +1,19 @@ false, 'archiveDate' => 'bar', 'dateTimeNotRequired' => true, - 'showImporter' => true, 'showAdministrationModule' => false, 'rteForTeaser' => false, 'storageUidImporter' => 1, @@ -50,7 +46,7 @@ public function settingsCanBeRead(): void } foreach ($configuration as $key => $value) { $functionName = 'get' . ucwords($key); - $this->assertEquals($value, $configurationInstance->$functionName()); + self::assertEquals($value, $configurationInstance->$functionName()); } } @@ -58,8 +54,6 @@ public function settingsCanBeRead(): void * Test if default settings can be read * * @test - * - * @return void */ public function defaultSettingsCanBeRead(): void { @@ -71,7 +65,6 @@ public function defaultSettingsCanBeRead(): void 'manualSorting' => false, 'archiveDate' => 'date', 'dateTimeNotRequired' => false, - 'showImporter' => false, 'showAdministrationModule' => true, 'rteForTeaser' => false, 'storageUidImporter' => 1, @@ -84,7 +77,7 @@ public function defaultSettingsCanBeRead(): void foreach ($configuration as $key => $value) { $functionName = 'get' . ucwords($key); - $this->assertEquals($value, $configurationInstance->$functionName()); + self::assertEquals($value, $configurationInstance->$functionName()); } } } diff --git a/Tests/Unit/Domain/Model/Dto/NewsDemandTest.php b/Tests/Unit/Domain/Model/Dto/NewsDemandTest.php index 87032da1cc..05fee90774 100644 --- a/Tests/Unit/Domain/Model/Dto/NewsDemandTest.php +++ b/Tests/Unit/Domain/Model/Dto/NewsDemandTest.php @@ -1,13 +1,14 @@ instance->setCategories($value); - $this->assertEquals($value, $this->instance->getCategories()); + self::assertEquals($value, $this->instance->getCategories()); } /** * @test - * - * @return void */ public function categoryConjunctionCanBeSet(): void { $value = 'AND'; $this->instance->setCategoryConjunction($value); - $this->assertEquals($value, $this->instance->getCategoryConjunction()); + self::assertEquals($value, $this->instance->getCategoryConjunction()); } /** * @test - * - * @return void */ public function includeSubCategoriesCanBeSet(): void { $value = true; $this->instance->setIncludeSubCategories($value); - $this->assertEquals($value, $this->instance->getIncludeSubCategories()); + self::assertEquals($value, $this->instance->getIncludeSubCategories()); } /** * @test - * - * @return void */ public function authorCanBeSet(): void { $value = '7elix'; $this->instance->setAuthor($value); - $this->assertEquals($value, $this->instance->getAuthor()); + self::assertEquals($value, $this->instance->getAuthor()); } /** * @test - * - * @return void */ public function tagsCanBeSet(): void { $value = '1,2,3'; $this->instance->setTags($value); - $this->assertEquals($value, $this->instance->getTags()); + self::assertEquals($value, $this->instance->getTags()); } /** * @test - * - * @return void */ public function archiveRestrictionCanBeSet(): void { $value = 'archive'; $this->instance->setArchiveRestriction($value); - $this->assertEquals($value, $this->instance->getArchiveRestriction()); + self::assertEquals($value, $this->instance->getArchiveRestriction()); } /** * @test - * - * @return void */ public function timeRestrictionCanBeSet(): void { $value = '2014-04-01'; $this->instance->setTimeRestriction($value); - $this->assertEquals($value, $this->instance->getTimeRestriction()); + self::assertEquals($value, $this->instance->getTimeRestriction()); } /** * @test - * - * @return void */ public function timeRestrictionHighCanBeSet(): void { $value = '2014-05-01'; $this->instance->setTimeRestrictionHigh($value); - $this->assertEquals($value, $this->instance->getTimeRestrictionHigh()); + self::assertEquals($value, $this->instance->getTimeRestrictionHigh()); } /** * @test - * - * @return void */ public function topNewsRestrictionCanBeSet(): void { $value = 1; $this->instance->setTopNewsRestriction($value); - $this->assertEquals($value, $this->instance->getTopNewsRestriction()); + self::assertEquals($value, $this->instance->getTopNewsRestriction()); } /** * @test - * - * @return void */ public function dateFieldCanBeSet(): void { $value = 'datetime'; $this->instance->setDateField($value); - $this->assertEquals($value, $this->instance->getDateField()); + self::assertEquals($value, $this->instance->getDateField()); $value = 'archive'; $this->instance->setDateField($value); - $this->assertEquals($value, $this->instance->getDateField()); + self::assertEquals($value, $this->instance->getDateField()); $value = 'invalid'; $this->instance->setDateField($value); - $this->assertEquals('', $this->instance->getDateField()); + self::assertEquals('', $this->instance->getDateField()); } /** * @test - * - * @return void */ public function monthCanBeSet(): void { $value = 4; $this->instance->setMonth($value); - $this->assertEquals($value, $this->instance->getMonth()); + self::assertEquals($value, $this->instance->getMonth()); } /** * @test - * - * @return void */ public function yearCanBeSet(): void { $value = 2014; $this->instance->setYear($value); - $this->assertEquals($value, $this->instance->getYear()); + self::assertEquals($value, $this->instance->getYear()); } /** * @test - * - * @return void */ public function dayCanBeSet(): void { $value = 1; $this->instance->setDay($value); - $this->assertEquals($value, $this->instance->getDay()); + self::assertEquals($value, $this->instance->getDay()); } /** * @test - * - * @return void */ public function searchFieldsCanBeSet(): void { $value = 'field1,field2'; $this->instance->setSearchFields($value); - $this->assertEquals($value, $this->instance->getSearchFields()); + self::assertEquals($value, $this->instance->getSearchFields()); } /** * @test - * - * @return void */ public function searchCanBeSet(): void { $value = new Search(); $value->setSubject('fo'); $this->instance->setSearch($value); - $this->assertEquals($value, $this->instance->getSearch()); + self::assertEquals($value, $this->instance->getSearch()); } /** * @test - * - * @return void */ public function orderCanBeSet(): void { $value = 'order'; $this->instance->setOrder($value); - $this->assertEquals($value, $this->instance->getOrder()); + self::assertEquals($value, $this->instance->getOrder()); } /** * @test - * - * @return void */ public function orderByAllowedCanBeSet(): void { $value = 'order,order2'; $this->instance->setOrderByAllowed($value); - $this->assertEquals($value, $this->instance->getOrderByAllowed()); + self::assertEquals($value, $this->instance->getOrderByAllowed()); } /** * @test - * - * @return void */ public function topNewsFirstCanBeSet(): void { $value = true; $this->instance->setTopNewsFirst($value); - $this->assertEquals($value, $this->instance->getTopNewsFirst()); + self::assertEquals($value, $this->instance->getTopNewsFirst()); } /** * @test - * - * @return void */ public function storagePageCanBeSet(): void { $value = 456; $this->instance->setStoragePage($value); - $this->assertEquals($value, $this->instance->getStoragePage()); + self::assertEquals($value, $this->instance->getStoragePage()); } /** * @test - * - * @return void */ public function limitCanBeSet(): void { $value = 10; $this->instance->setLimit($value); - $this->assertEquals($value, $this->instance->getLimit()); + self::assertEquals($value, $this->instance->getLimit()); } /** * @test - * - * @return void */ public function offsetCanBeSet(): void { $value = 20; $this->instance->setOffset($value); - $this->assertEquals($value, $this->instance->getOffset()); + self::assertEquals($value, $this->instance->getOffset()); } /** * @test - * - * @return void */ public function excludeAlreadyDisplayedNewsCanBeSet(): void { $value = true; $this->instance->setExcludeAlreadyDisplayedNews($value); - $this->assertEquals($value, $this->instance->getExcludeAlreadyDisplayedNews()); + self::assertEquals($value, $this->instance->getExcludeAlreadyDisplayedNews()); } /** * @test - * - * @return void */ public function hideIdListCanBeSet(): void { $value = '123,456'; $this->instance->setHideIdList($value); - $this->assertEquals($value, $this->instance->getHideIdList()); + self::assertEquals($value, $this->instance->getHideIdList()); } /** * @test - * - * @return void */ public function actionCanBeSet(): void { $value = 'anAction'; $this->instance->setAction($value); - $this->assertEquals($value, $this->instance->getAction()); + self::assertEquals($value, $this->instance->getAction()); } /** * @test - * - * @return void */ public function classCanBeSet(): void { $value = 'FooBar'; $this->instance->setClass($value); - $this->assertEquals($value, $this->instance->getClass()); + self::assertEquals($value, $this->instance->getClass()); } /** * @test - * - * @return void */ public function typesCanBeSet(): void { $value = ['12', '34']; $this->instance->setTypes($value); - $this->assertEquals($value, $this->instance->getTypes()); + self::assertEquals($value, $this->instance->getTypes()); } } diff --git a/Tests/Unit/Domain/Model/Dto/SearchTest.php b/Tests/Unit/Domain/Model/Dto/SearchTest.php index a5797e6129..4d456fb42e 100644 --- a/Tests/Unit/Domain/Model/Dto/SearchTest.php +++ b/Tests/Unit/Domain/Model/Dto/SearchTest.php @@ -1,19 +1,19 @@ setSubject($subject); - $this->assertEquals($subject, $domainModelInstance->getSubject()); + self::assertEquals($subject, $domainModelInstance->getSubject()); } /** * Test if fields can be set * * @test - * - * @return void */ public function fieldsCanBeSet(): void { $domainModelInstance = new Search(); $fields = 'field1,field2'; $domainModelInstance->setFields($fields); - $this->assertEquals($fields, $domainModelInstance->getFields()); + self::assertEquals($fields, $domainModelInstance->getFields()); } /** * Test if minimumDate can be set * * @test - * - * @return void */ public function minimumDateCanBeSet(): void { $domainModelInstance = new Search(); $value = '123'; $domainModelInstance->setMinimumDate($value); - $this->assertEquals($value, $domainModelInstance->getMinimumDate()); + self::assertEquals($value, $domainModelInstance->getMinimumDate()); } /** * Test if minimumDate can be set * * @test - * - * @return void */ public function maximumDateCanBeSet(): void { $domainModelInstance = new Search(); $value = '456'; $domainModelInstance->setMaximumDate($value); - $this->assertEquals($value, $domainModelInstance->getMaximumDate()); + self::assertEquals($value, $domainModelInstance->getMaximumDate()); } } diff --git a/Tests/Unit/Domain/Model/FileReferenceTest.php b/Tests/Unit/Domain/Model/FileReferenceTest.php index 69a2ccd570..b69a7f9dc6 100644 --- a/Tests/Unit/Domain/Model/FileReferenceTest.php +++ b/Tests/Unit/Domain/Model/FileReferenceTest.php @@ -1,13 +1,14 @@ setFileUid($value); - $this->assertEquals($value, $domainModelInstance->getFileUid()); + self::assertEquals($value, $domainModelInstance->getFileUid()); } /** * Test if alternative can be set * * @test - * - * @return void */ public function alternativeBeSet(): void { $domainModelInstance = new FileReference(); $value = 'Test 123'; $domainModelInstance->setAlternative($value); - $this->assertEquals($value, $domainModelInstance->getAlternative()); + self::assertEquals($value, $domainModelInstance->getAlternative()); } /** * Test if description can be set * * @test - * - * @return void */ public function descriptionBeSet(): void { $domainModelInstance = new FileReference(); $value = 'Test 123'; $domainModelInstance->setDescription($value); - $this->assertEquals($value, $domainModelInstance->getDescription()); + self::assertEquals($value, $domainModelInstance->getDescription()); } /** * Test if link can be set * * @test - * - * @return void */ public function linkBeSet(): void { $domainModelInstance = new FileReference(); $value = 'Test 123'; $domainModelInstance->setLink($value); - $this->assertEquals($value, $domainModelInstance->getLink()); + self::assertEquals($value, $domainModelInstance->getLink()); } /** * Test if title can be set * * @test - * - * @return void */ public function titleBeSet(): void { $domainModelInstance = new FileReference(); $value = 'Test 123'; $domainModelInstance->setTitle($value); - $this->assertEquals($value, $domainModelInstance->getTitle()); + self::assertEquals($value, $domainModelInstance->getTitle()); } /** * Test if showInPreview can be set * * @test - * - * @return void */ public function showInPreviewBeSet(): void { $domainModelInstance = new FileReference(); $value = 2; $domainModelInstance->setShowinpreview($value); - $this->assertEquals($value, $domainModelInstance->getShowinpreview()); + self::assertEquals($value, $domainModelInstance->getShowinpreview()); } } diff --git a/Tests/Unit/Domain/Model/LinkTest.php b/Tests/Unit/Domain/Model/LinkTest.php index 7192c1c089..6ffe9f0003 100644 --- a/Tests/Unit/Domain/Model/LinkTest.php +++ b/Tests/Unit/Domain/Model/LinkTest.php @@ -1,13 +1,14 @@ linkDomainModelInstance->setTitle($title); - $this->assertEquals($title, $this->linkDomainModelInstance->getTitle()); + self::assertEquals($title, $this->linkDomainModelInstance->getTitle()); } /** * Test if crdate can be set * * @test - * - * @return void */ public function crdateCanBeSet(): void { $time = new \DateTime(); $this->linkDomainModelInstance->setCrdate($time); - $this->assertEquals($time, $this->linkDomainModelInstance->getCrdate()); + self::assertEquals($time, $this->linkDomainModelInstance->getCrdate()); } /** * Test if tstamp can be set * * @test - * - * @return void */ public function tstampCanBeSet(): void { $time = new \DateTime(); $this->linkDomainModelInstance->setTstamp($time); - $this->assertEquals($time, $this->linkDomainModelInstance->getTstamp()); + self::assertEquals($time, $this->linkDomainModelInstance->getTstamp()); } /** * Test if description can be set * * @test - * - * @return void */ public function descriptionCanBeSet(): void { $description = 'This is a description'; $this->linkDomainModelInstance->setDescription($description); - $this->assertEquals($description, $this->linkDomainModelInstance->getDescription()); + self::assertEquals($description, $this->linkDomainModelInstance->getDescription()); } /** * Test if uri can be set * * @test - * - * @return void */ public function uriCanBeSet(): void { $uri = 'http://typo3.org'; $this->linkDomainModelInstance->setUri($uri); - $this->assertEquals($uri, $this->linkDomainModelInstance->getUri()); + self::assertEquals($uri, $this->linkDomainModelInstance->getUri()); } } diff --git a/Tests/Unit/Domain/Model/NewsTest.php b/Tests/Unit/Domain/Model/NewsTest.php index 0cc5499213..999146198a 100644 --- a/Tests/Unit/Domain/Model/NewsTest.php +++ b/Tests/Unit/Domain/Model/NewsTest.php @@ -1,15 +1,16 @@ newsDomainModelInstance->setTitle($title); - $this->assertEquals($title, $this->newsDomainModelInstance->getTitle()); + self::assertEquals($title, $this->newsDomainModelInstance->getTitle()); } /** * Test if teaser can be set * * @test - * - * @return void */ public function teaserCanBeSet(): void { $teaser = 'News teaser'; $this->newsDomainModelInstance->setTeaser($teaser); - $this->assertEquals($teaser, $this->newsDomainModelInstance->getTeaser()); + self::assertEquals($teaser, $this->newsDomainModelInstance->getTeaser()); } /** * Test if bodytext can be set * * @test - * - * @return void */ public function bodytextCanBeSet(): void { $bodytext = 'News bodytext'; $this->newsDomainModelInstance->setBodytext($bodytext); - $this->assertEquals($bodytext, $this->newsDomainModelInstance->getBodytext()); + self::assertEquals($bodytext, $this->newsDomainModelInstance->getBodytext()); } /** * Test if datetime can be set * * @test - * - * @return void */ public function datetimeCanBeSet(): void { $datetime = new \DateTime(); $this->newsDomainModelInstance->setDatetime($datetime); - $this->assertEquals($datetime, $this->newsDomainModelInstance->getDatetime()); + self::assertEquals($datetime, $this->newsDomainModelInstance->getDatetime()); } /** * Test if archive can be set * * @test - * - * @return void */ public function archiveCanBeSet(): void { $archive = new \DateTime(); $this->newsDomainModelInstance->setArchive($archive); - $this->assertEquals($archive, $this->newsDomainModelInstance->getArchive()); + self::assertEquals($archive, $this->newsDomainModelInstance->getArchive()); } /** * Test if author can be set * * @test - * - * @return void */ public function authorCanBeSet(): void { $author = 'News author'; $this->newsDomainModelInstance->setAuthor($author); - $this->assertEquals($author, $this->newsDomainModelInstance->getAuthor()); + self::assertEquals($author, $this->newsDomainModelInstance->getAuthor()); } /** * Test if emailadr can be set * * @test - * - * @return void */ public function authorEmailCanBeSet(): void { $authorEmail = 'author@news.org'; $this->newsDomainModelInstance->setAuthorEmail($authorEmail); - $this->assertEquals($authorEmail, $this->newsDomainModelInstance->getAuthorEmail()); + self::assertEquals($authorEmail, $this->newsDomainModelInstance->getAuthorEmail()); } /** * Test if type can be set * * @test - * - * @return void */ public function typeCanBeSet(): void { $type = 123; $this->newsDomainModelInstance->setType($type); - $this->assertEquals($type, $this->newsDomainModelInstance->getType()); + self::assertEquals($type, $this->newsDomainModelInstance->getType()); } /** * Test if keyword can be set * * @test - * - * @return void */ public function keywordsCanBeSet(): void { $keywords = 'news1 keyword, news keyword'; $this->newsDomainModelInstance->setKeywords($keywords); - $this->assertEquals($keywords, $this->newsDomainModelInstance->getKeywords()); + self::assertEquals($keywords, $this->newsDomainModelInstance->getKeywords()); } /** * Test if internalurl can be set * * @test - * - * @return void */ public function internalurlCanBeSet(): void { $internalurl = 'http://foo.org/'; $this->newsDomainModelInstance->setInternalurl($internalurl); - $this->assertEquals($internalurl, $this->newsDomainModelInstance->getInternalurl()); + self::assertEquals($internalurl, $this->newsDomainModelInstance->getInternalurl()); } /** * Test if externalurl can be set * * @test - * - * @return void */ public function externalurlCanBeSet(): void { $externalurl = 'http://bar.org/'; $this->newsDomainModelInstance->setExternalurl($externalurl); - $this->assertEquals($externalurl, $this->newsDomainModelInstance->getExternalurl()); + self::assertEquals($externalurl, $this->newsDomainModelInstance->getExternalurl()); } /** * Test if topnews can be set * * @test - * - * @return void */ public function isttopnewsCanBeSet(): void { $istopnews = true; $this->newsDomainModelInstance->setIstopnews($istopnews); - $this->assertEquals($istopnews, $this->newsDomainModelInstance->getIstopnews()); + self::assertEquals($istopnews, $this->newsDomainModelInstance->getIstopnews()); } /** * Test if editlock can be set * * @test - * - * @return void */ public function editlockCanBeSet(): void { $editlock = 2; $this->newsDomainModelInstance->setEditlock($editlock); - $this->assertEquals($editlock, $this->newsDomainModelInstance->getEditlock()); + self::assertEquals($editlock, $this->newsDomainModelInstance->getEditlock()); } /** * Test if importid can be set * * @test - * - * @return void */ public function importIdCanBeSet(): void { $importId = 2; $this->newsDomainModelInstance->setImportId($importId); - $this->assertEquals($importId, $this->newsDomainModelInstance->getImportId()); + self::assertEquals($importId, $this->newsDomainModelInstance->getImportId()); } /** * Test if importSource can be set * * @test - * - * @return void */ public function importSourceCanBeSet(): void { $importSource = 'test'; $this->newsDomainModelInstance->setImportSource($importSource); - $this->assertEquals($importSource, $this->newsDomainModelInstance->getImportSource()); + self::assertEquals($importSource, $this->newsDomainModelInstance->getImportSource()); } /** * Test if sorting can be set * * @test - * - * @return void */ public function sortingCanBeSet(): void { $sorting = 2; $this->newsDomainModelInstance->setSorting($sorting); - $this->assertEquals($sorting, $this->newsDomainModelInstance->getSorting()); + self::assertEquals($sorting, $this->newsDomainModelInstance->getSorting()); } /** * Test if tag can be set * * @test - * - * @return void */ public function tagsCanBeSet(): void { @@ -276,15 +241,13 @@ public function tagsCanBeSet(): void $tag->setTitle('Tag'); $tags->attach($tag); $this->newsDomainModelInstance->setTags($tags); - $this->assertEquals($tags, $this->newsDomainModelInstance->getTags()); + self::assertEquals($tags, $this->newsDomainModelInstance->getTags()); } /** * Test if content elements can be set * * @test - * - * @return void */ public function contentElementsCanBeSet(): void { @@ -294,15 +257,13 @@ public function contentElementsCanBeSet(): void $ce->attach($item); $this->newsDomainModelInstance->setContentElements($ce); - $this->assertEquals($ce, $this->newsDomainModelInstance->getContentElements()); + self::assertEquals($ce, $this->newsDomainModelInstance->getContentElements()); } /** * Test if category can be set * * @test - * - * @return void */ public function categoryCanBeSet(): void { @@ -311,15 +272,13 @@ public function categoryCanBeSet(): void $categories = new ObjectStorage(); $categories->attach($category); $this->newsDomainModelInstance->setCategories($categories); - $this->assertEquals($categories, $this->newsDomainModelInstance->getCategories()); + self::assertEquals($categories, $this->newsDomainModelInstance->getCategories()); } /** * Test if related links can be set * * @test - * - * @return void */ public function relatedLinksCanBeSet(): void { @@ -329,13 +288,11 @@ public function relatedLinksCanBeSet(): void $related = new ObjectStorage(); $related->attach($link); $this->newsDomainModelInstance->setRelatedLinks($related); - $this->assertEquals($related, $this->newsDomainModelInstance->getRelatedLinks()); + self::assertEquals($related, $this->newsDomainModelInstance->getRelatedLinks()); } /** * @test - * - * @return void */ public function falMediaCanBeAdded(): void { @@ -345,14 +302,12 @@ public function falMediaCanBeAdded(): void $news = new News(); $news->addFalMedia($mediaItem); - $this->assertEquals($news->getFalMedia()->current(), $mediaItem); - $this->assertEquals($news->getMedia()->current(), $mediaItem); + self::assertEquals($news->getFalMedia()->current(), $mediaItem); + self::assertEquals($news->getMedia()->current(), $mediaItem); } /** * @test - * - * @return void */ public function falMediaPreviewsAreReturned(): void { @@ -361,7 +316,7 @@ public function falMediaPreviewsAreReturned(): void $mockedElement1 = $this->getAccessibleMock(FileReference::class, ['getProperty']); $mockedElement1->_set('uid', 1); $mockedElement1->_set('showinpreview', 1); - $mockedElement1->expects($this->any())->method('getProperty')->will($this->returnValue(1)); + $mockedElement1->expects(self::any())->method('getProperty')->willReturn(1); $mediaItem1 = new FileReference(); $mediaItem1->_setProperty('originalResource', $mockedElement1); @@ -371,7 +326,7 @@ public function falMediaPreviewsAreReturned(): void $mockedElement2 = $this->getAccessibleMock(FileReference::class, ['getProperty']); $mockedElement2->_set('uid', 2); $mockedElement2->_set('showinpreview', 0); - $mockedElement2->expects($this->any())->method('getProperty')->will($this->returnValue(0)); + $mockedElement2->expects(self::any())->method('getProperty')->willReturn(0); $mediaItem2 = new FileReference(); $mediaItem2->_setProperty('originalResource', $mockedElement2); @@ -381,7 +336,7 @@ public function falMediaPreviewsAreReturned(): void $mockedElement3 = $this->getAccessibleMock(FileReference::class, ['getProperty']); $mockedElement3->_set('uid', 3); $mockedElement3->_set('showinpreview', 1); - $mockedElement3->expects($this->any())->method('getProperty')->will($this->returnValue(1)); + $mockedElement3->expects(self::any())->method('getProperty')->willReturn(1); $mediaItem3 = new FileReference(); $mediaItem3->_setProperty('uid', 3); @@ -391,17 +346,17 @@ public function falMediaPreviewsAreReturned(): void $mockedElement4 = $this->getAccessibleMock(FileReference::class, ['getProperty']); $mockedElement4->_set('uid', 4); $mockedElement4->_set('showinpreview', 2); - $mockedElement4->expects($this->any())->method('getProperty')->will($this->returnValue(2)); + $mockedElement4->expects(self::any())->method('getProperty')->willReturn(2); $mediaItem4 = new FileReference(); $mediaItem4->_setProperty('uid', 4); $mediaItem4->_setProperty('originalResource', $mockedElement4); $news->addFalMedia($mediaItem4); - $this->assertEquals(3, count($news->getMediaPreviews())); - $this->assertEquals(3, count($news->getMediaNonPreviews())); + self::assertEquals(3, count($news->getMediaPreviews())); + self::assertEquals(3, count($news->getMediaNonPreviews())); - $this->assertEquals(4, count($news->getFalMedia())); - $this->assertEquals(4, count($news->getMedia())); + self::assertEquals(4, count($news->getFalMedia())); + self::assertEquals(4, count($news->getMedia())); } } diff --git a/Tests/Unit/Domain/Model/TagTest.php b/Tests/Unit/Domain/Model/TagTest.php index bd3e892563..4645cf1aae 100644 --- a/Tests/Unit/Domain/Model/TagTest.php +++ b/Tests/Unit/Domain/Model/TagTest.php @@ -1,19 +1,19 @@ tagDomainModelInstance->setTitle($title); - $this->assertEquals($title, $this->tagDomainModelInstance->getTitle()); + self::assertEquals($title, $this->tagDomainModelInstance->getTitle()); } /** * Test if crdate can be set * * @test - * - * @return void */ public function crdateCanBeSet(): void { $time = new \DateTime('now'); $this->tagDomainModelInstance->setCrdate($time); - $this->assertEquals($time, $this->tagDomainModelInstance->getCrdate()); + self::assertEquals($time, $this->tagDomainModelInstance->getCrdate()); } /** * Test if tstamp can be set * * @test - * - * @return void */ public function tstampCanBeSet(): void { $time = new \DateTime('now'); $this->tagDomainModelInstance->setTstamp($time); - $this->assertEquals($time, $this->tagDomainModelInstance->getTstamp()); + self::assertEquals($time, $this->tagDomainModelInstance->getTstamp()); } } diff --git a/Tests/Unit/Domain/Model/TtContentTest.php b/Tests/Unit/Domain/Model/TtContentTest.php index 698bab7faf..c8853b9ffb 100644 --- a/Tests/Unit/Domain/Model/TtContentTest.php +++ b/Tests/Unit/Domain/Model/TtContentTest.php @@ -1,19 +1,19 @@ ttContentDomainModelInstance->setCrdate($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCrdate()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCrdate()); } /** * @test - * - * @return void */ public function tstampCanBeSet(): void { $fieldValue = new \DateTime(); $this->ttContentDomainModelInstance->setTstamp($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getTstamp()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getTstamp()); } /** * @test - * - * @return void */ public function cTypeCanBeSet(): void { $fieldValue = 'fo123'; $this->ttContentDomainModelInstance->setCType($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCType()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCType()); } /** * @test - * - * @return void */ public function headerCanBeSet(): void { $fieldValue = 'fo123'; $this->ttContentDomainModelInstance->setHeader($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeader()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeader()); } /** * @test - * - * @return void */ public function headerPositionCanBeSet(): void { $fieldValue = 'fo123'; $this->ttContentDomainModelInstance->setHeaderPosition($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderPosition()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderPosition()); } /** * @test - * - * @return void */ public function bodytextCanBeSet(): void { $fieldValue = 'fo123'; $this->ttContentDomainModelInstance->setBodytext($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getBodytext()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getBodytext()); } /** * @test - * - * @return void */ public function colPosCanBeSet(): void { $fieldValue = 1; $this->ttContentDomainModelInstance->setColPos($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getColPos()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getColPos()); } /** * @test - * - * @return void */ public function imageCanBeSet(): void { $fieldValue = 'fo123'; $this->ttContentDomainModelInstance->setImage($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImage()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImage()); } /** * @test - * - * @return void */ public function imageWidthCanBeSet(): void { $fieldValue = 123; $this->ttContentDomainModelInstance->setImagewidth($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagewidth()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagewidth()); } /** * @test - * - * @return void */ public function imageOrientCanBeSet(): void { $fieldValue = 3; $this->ttContentDomainModelInstance->setImageorient($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageorient()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageorient()); } /** * @test - * - * @return void */ public function imageCaptionCanBeSet(): void { $fieldValue = 'Test123'; $this->ttContentDomainModelInstance->setImagecaption($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagecaption()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagecaption()); } /** * @test - * - * @return void */ public function imageColsCanBeSet(): void { $fieldValue = 123; $this->ttContentDomainModelInstance->setImagecols($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagecols()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagecols()); } /** * @test - * - * @return void */ public function imageBorderCanBeSet(): void { $fieldValue = 123; $this->ttContentDomainModelInstance->setImageborder($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageborder()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageborder()); } /** * @test - * - * @return void */ public function mediaCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setMedia($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getMedia()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getMedia()); } /** * @test - * - * @return void */ public function layoutCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setLayout($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getLayout()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getLayout()); } /** * @test - * - * @return void */ public function colsCanBeSet(): void { $fieldValue = 123; $this->ttContentDomainModelInstance->setCols($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCols()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCols()); } /** * @test - * - * @return void */ public function subheaderCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setSubheader($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getSubheader()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getSubheader()); } /** * @test - * - * @return void */ public function headerLinkCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setHeaderLink($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderLink()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderLink()); } /** * @test - * - * @return void */ public function imageLinkCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setImageLink($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageLink()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageLink()); } /** * @test - * - * @return void */ public function imageZoomCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setImageZoom($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageZoom()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageZoom()); } /** * @test - * - * @return void */ public function altTextCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setAltText($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getAltText()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getAltText()); } /** * @test - * - * @return void */ public function titleTextCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setTitleText($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getTitleText()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getTitleText()); } /** * @test - * - * @return void */ public function headerLayoutCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setHeaderLayout($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderLayout()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderLayout()); } /** * @test - * - * @return void */ public function listTypeCanBeSet(): void { $fieldValue = 'Test 123'; $this->ttContentDomainModelInstance->setListType($fieldValue); - $this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getListType()); + self::assertEquals($fieldValue, $this->ttContentDomainModelInstance->getListType()); } } diff --git a/Tests/Unit/Domain/Repository/CategoryRepositoryTest.php b/Tests/Unit/Domain/Repository/CategoryRepositoryTest.php index 2714b5a51d..773b25019a 100644 --- a/Tests/Unit/Domain/Repository/CategoryRepositoryTest.php +++ b/Tests/Unit/Domain/Repository/CategoryRepositoryTest.php @@ -1,20 +1,19 @@ _call('replaceCategoryIds', $given['idList'], $given['toBeChanged']); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } /** @@ -51,8 +48,8 @@ public function categoryIdsAreCorrectlyReplacedDataProvider(): array [1, 2, 3], [ 'idList' => [1, 2, 3], - 'toBeChanged' => [] - ] + 'toBeChanged' => [], + ], ], 'oneIdReplaced' => [ [1, 5, 3], @@ -62,9 +59,9 @@ public function categoryIdsAreCorrectlyReplacedDataProvider(): array 0 => [ 'l10n_parent' => 2, 'uid' => 5, - ] - ] - ] + ], + ], + ], ], 'noIdReplaced' => [ [1, 2, 3], @@ -78,9 +75,9 @@ public function categoryIdsAreCorrectlyReplacedDataProvider(): array 1 => [ 'l10n_parent' => 8, 'uid' => 10, - ] - ] - ] + ], + ], + ], ], 'allIdsReplaced' => [ [4, 5, 6], @@ -102,9 +99,9 @@ public function categoryIdsAreCorrectlyReplacedDataProvider(): array [ 'l10n_parent' => 8, 'uid' => 10, - ] - ] - ] + ], + ], + ], ], ]; } diff --git a/Tests/Unit/Domain/Repository/NewsRepositoryTest.php b/Tests/Unit/Domain/Repository/NewsRepositoryTest.php index 0f6bd943c6..b5fed65fd1 100644 --- a/Tests/Unit/Domain/Repository/NewsRepositoryTest.php +++ b/Tests/Unit/Domain/Repository/NewsRepositoryTest.php @@ -1,26 +1,29 @@ mockedNewsRepository = $this->getAccessibleMock(NewsRepository::class, ['getQueryBuilder'], [], '', false); $mockedQueryBuilder = $this->getAccessibleMock(QueryBuilder::class, ['escapeStrForLike', 'createNamedParameter'], [], '', false); - $this->mockedNewsRepository->expects($this->any())->method('getQueryBuilder')->withAnyParameters()->will($this->returnValue($mockedQueryBuilder)); + $this->mockedNewsRepository->expects(self::any())->method('getQueryBuilder')->withAnyParameters()->willReturn($mockedQueryBuilder); } /** * @test - * - * @return void */ public function getSearchConstraintsThrowsErrorIfNoSearchFieldIsGiven(): void { @@ -56,8 +57,6 @@ public function getSearchConstraintsThrowsErrorIfNoSearchFieldIsGiven(): void // /** * @test - * - * @return void */ public function getSearchConstraintsThrowsErrorIfNoDateFieldForMaximumDateIsGiven(): void { @@ -75,8 +74,6 @@ public function getSearchConstraintsThrowsErrorIfNoDateFieldForMaximumDateIsGive // /** * @test - * - * @return void */ public function getSearchConstraintsThrowsErrorIfNoDateFieldForMinimumDateIsGiven(): void { @@ -95,8 +92,6 @@ public function getSearchConstraintsThrowsErrorIfNoDateFieldForMinimumDateIsGive // /** * @test - * - * @return void */ public function emptyConstraintIsReturnedForEmptySearchDemand(): void { @@ -105,18 +100,23 @@ public function emptyConstraintIsReturnedForEmptySearchDemand(): void $demand = new NewsDemand(); $demand->setSearch(null); $result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand); - $this->assertEmpty($result); + self::assertEmpty($result); } /** * @test - * - * @return void */ public function constraintsAreReturnedForSearchSubject(): void { + $stmt1 = new Statement(''); + $stmt2 = new Statement(''); + $propertyValue = new PropertyValue('dummy', ''); + $like = new Comparison($propertyValue, 1, ''); $mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock(); + $mockedQuery->expects(self::any())->method('like')->willReturn($like); + $or = GeneralUtility::makeInstance(LogicalOr::class, $stmt1, $stmt2); + $mockedQuery->expects(self::any())->method('logicalOr')->willReturn($or); $search = new Search(); $search->setSubject('Lorem'); $search->setFields('title,fo'); @@ -125,13 +125,11 @@ public function constraintsAreReturnedForSearchSubject(): void $demand->setSearch($search); $result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); } /** * @test - * - * @return void */ public function constraintsAreReturnedForDateFields(): void { @@ -145,18 +143,18 @@ public function constraintsAreReturnedForDateFields(): void $demand->setSearch($search); $result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); $search->setMaximumDate('2015-01-01'); $demand->setSearch($search); $result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); $search->setMaximumDate('xyz'); $demand->setSearch($search); $result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); } } diff --git a/Tests/Unit/Hooks/PageLayoutViewTest.php b/Tests/Unit/Hooks/PluginPreviewRendererTest.php similarity index 72% rename from Tests/Unit/Hooks/PageLayoutViewTest.php rename to Tests/Unit/Hooks/PluginPreviewRendererTest.php index 659a6736ae..e7bae83d9c 100644 --- a/Tests/Unit/Hooks/PageLayoutViewTest.php +++ b/Tests/Unit/Hooks/PluginPreviewRendererTest.php @@ -1,26 +1,25 @@ getAccessibleMock(LanguageService::class, ['sl'], [], '', false, false); - $languageService->expects($this->any())->method('sL')->will($this->returnValue('any language')); + $languageService->expects(self::any())->method('sL')->willReturn('any language'); $GLOBALS['LANG'] = $languageService; - $this->pageLayoutView = $this->getAccessibleMock(PageLayoutView::class, ['dummy'], [], '', false); + $this->pageLayoutView = $this->getAccessibleMock(PluginPreviewRenderer::class, ['dummy'], [], '', false); $this->pageLayoutView->_set('databaseConnection', $this->getMockBuilder('TYPO3\CMS\\Core\\Utility\\GeneralUtility\\DatabaseConnection')->setMethods(['exec_SELECTquery', 'exec_SELECTgetRows'])->getMock()); } /** * @test - * - * @return void */ public function getArchiveSettingAddsValueIfFilled(): void { @@ -48,13 +45,11 @@ public function getArchiveSettingAddsValueIfFilled(): void $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getArchiveSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getDetailPidSettingAddsValueIfFilled(): void { @@ -63,13 +58,11 @@ public function getDetailPidSettingAddsValueIfFilled(): void $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getDetailPidSetting'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getTagRestrictionSettingAddsValueIfFilled(): void { @@ -78,13 +71,11 @@ public function getTagRestrictionSettingAddsValueIfFilled(): void $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getTagRestrictionSetting'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getListPidSettingAddsValueIfFilled(): void { @@ -93,13 +84,11 @@ public function getListPidSettingAddsValueIfFilled(): void $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getListPidSetting'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getOrderBySettingAddsValueIfFilled(): void { @@ -108,47 +97,41 @@ public function getOrderBySettingAddsValueIfFilled(): void $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getOrderSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getOrderDirectionSettingAddsValueIfFilled(): void { $flexform = []; $this->addContentToFlexform($flexform, 'settings.orderDirection', 'asc'); - $this->assertEquals($this->pageLayoutView->_call('getOrderDirectionSetting'), ''); + self::assertEquals($this->pageLayoutView->_call('getOrderDirectionSetting'), ''); $this->pageLayoutView->_set('flexformData', $flexform); $out = $this->pageLayoutView->_call('getOrderDirectionSetting'); - $this->assertEquals((strlen($out) > 1), true); + self::assertEquals((strlen($out) > 1), true); } /** * @test - * - * @return void */ public function getTopNewsFirstSettingAddsValueIfFilled(): void { $flexform = []; $this->addContentToFlexform($flexform, 'settings.topNewsFirst', '1', 'additional'); - $this->assertEquals($this->pageLayoutView->_call('getTopNewsFirstSetting'), ''); + self::assertEquals($this->pageLayoutView->_call('getTopNewsFirstSetting'), ''); $this->pageLayoutView->_set('flexformData', $flexform); $out = $this->pageLayoutView->_call('getTopNewsFirstSetting'); - $this->assertEquals((strlen($out) > 1), true); + self::assertEquals((strlen($out) > 1), true); } /** * @test - * - * @return void */ public function getOffsetLimitSettingsAddsValueIfFilled(): void { @@ -156,28 +139,26 @@ public function getOffsetLimitSettingsAddsValueIfFilled(): void $this->addContentToFlexform($flexform, 'settings.offset', '1', 'additional'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getOffsetLimitSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); $this->addContentToFlexform($flexform, 'settings.limit', '1', 'additional'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getOffsetLimitSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 2); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 2); $this->addContentToFlexform($flexform, 'settings.hidePagination', '0', 'additional'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getOffsetLimitSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 2); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 2); $this->addContentToFlexform($flexform, 'settings.hidePagination', '1', 'additional'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getOffsetLimitSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 3); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 3); } /** * @test - * - * @return void */ public function getDateMenuSettingsAddsValueIfFilled(): void { @@ -185,13 +166,11 @@ public function getDateMenuSettingsAddsValueIfFilled(): void $this->addContentToFlexform($flexform, 'settings.dateField', 'field'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getDateMenuSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getTimeRestrictionSettingAddsValueIfFilled(): void { @@ -199,38 +178,34 @@ public function getTimeRestrictionSettingAddsValueIfFilled(): void $this->addContentToFlexform($flexform, 'settings.timeRestriction', 'fo'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getTimeRestrictionSetting'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); $this->addContentToFlexform($flexform, 'settings.timeRestrictionHigh', 'bar'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getTimeRestrictionSetting'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 2); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 2); } /** * @test - * - * @return void */ public function getTemplateLayoutSettingsAddsValueIfFilled(): void { $flexform = []; $mockedTemplateLayout = $this->getAccessibleMock(TemplateLayout::class, ['getAvailableTemplateLayouts']); - $mockedTemplateLayout->expects($this->once())->method('getAvailableTemplateLayouts')->will($this->returnValue([['bar', 'fo']])); + $mockedTemplateLayout->expects(self::once())->method('getAvailableTemplateLayouts')->willReturn([['bar', 'fo']]); $this->addContentToFlexform($flexform, 'settings.templateLayout', 'fo', 'template'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_set('templateLayoutsUtility', $mockedTemplateLayout); $this->pageLayoutView->_call('getTemplateLayoutSettings', 1); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** * @test - * - * @return void */ public function getOverrideDemandSettingsAddsValueIfFilled(): void { @@ -238,7 +213,7 @@ public function getOverrideDemandSettingsAddsValueIfFilled(): void $this->addContentToFlexform($flexform, 'settings.disableOverrideDemand', '1', 'additional'); $this->pageLayoutView->_set('flexformData', $flexform); $this->pageLayoutView->_call('getOverrideDemandSettings'); - $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1); + self::assertEquals(count($this->pageLayoutView->_get('tableData')), 1); } /** @@ -248,8 +223,6 @@ public function getOverrideDemandSettingsAddsValueIfFilled(): void * @param string $key key of field * @param string $value value of field * @param string $sheet name of sheet - * - * @return void */ protected function addContentToFlexform(array &$flexform, $key, $value, $sheet = 'sDEF'): void { @@ -258,11 +231,11 @@ protected function addContentToFlexform(array &$flexform, $key, $value, $sheet = $sheet => [ 'lDEF' => [ $key => [ - 'vDEF' => $value - ] - ] - ] - ] + 'vDEF' => $value, + ], + ], + ], + ], ]; } } diff --git a/Tests/Unit/Service/CategoryServiceTest.php b/Tests/Unit/Service/CategoryServiceTest.php index 9a8e256e54..5f23387d43 100644 --- a/Tests/Unit/Service/CategoryServiceTest.php +++ b/Tests/Unit/Service/CategoryServiceTest.php @@ -1,19 +1,19 @@ assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -39,19 +37,19 @@ public function removeValuesFromStringDataProvider() { return [ 'simpleExampleWithRemovalAtEnd' => [ - '1,2,3,4', ['1,2,3,4,5', '5'] + '1,2,3,4', ['1,2,3,4,5', '5'], ], 'simpleExampleWithMixedRemovals' => [ - '1,2,3,4', ['1,7,2,9,3,4', '9,7'] + '1,2,3,4', ['1,7,2,9,3,4', '9,7'], ], 'removalIsSame' => [ - '', ['1,2,3', '3,2,1'] + '', ['1,2,3', '3,2,1'], ], 'noRemovalFound' => [ - '1,2,3', ['1,2,3', '9,8,7'] + '1,2,3', ['1,2,3', '9,8,7'], ], 'noInputGiven' => [ - '', ['', '9,8,7'] + '', ['', '9,8,7'], ], ]; } diff --git a/Tests/Unit/Utility/ImportJobTest.php b/Tests/Unit/Utility/ImportJobTest.php index a4411c9ab3..7cf33c4c5d 100644 --- a/Tests/Unit/Utility/ImportJobTest.php +++ b/Tests/Unit/Utility/ImportJobTest.php @@ -1,50 +1,48 @@ assertEquals($importJobInstance->getRegisteredJobs(), $jobs); + self::assertEquals($importJobInstance->getRegisteredJobs(), $jobs); // Add job #1 $jobs[] = [ 'className' => 'Class 1', 'title' => 'Some title', - 'description' => '' + 'description' => '', ]; $importJobInstance->register('Class 1', 'Some title', ''); - $this->assertEquals($importJobInstance->getRegisteredJobs(), $jobs); + self::assertEquals($importJobInstance->getRegisteredJobs(), $jobs); // Add job #2 $jobs[] = [ 'className' => 'Class 2', 'title' => '', - 'description' => 'Some description' + 'description' => 'Some description', ]; $importJobInstance->register('Class 2', '', 'Some description'); - $this->assertEquals($importJobInstance->getRegisteredJobs(), $jobs); + self::assertEquals($importJobInstance->getRegisteredJobs(), $jobs); } } diff --git a/Tests/Unit/Utility/TemplateLayoutTest.php b/Tests/Unit/Utility/TemplateLayoutTest.php index 3e35a7cde3..e64e88b75b 100644 --- a/Tests/Unit/Utility/TemplateLayoutTest.php +++ b/Tests/Unit/Utility/TemplateLayoutTest.php @@ -1,14 +1,14 @@ [ 0 => 'Layout 1', - 1 => 'layout1' + 1 => 'layout1', ], 1 => [ 0 => 'Layout 2', - 1 => 'layout2' + 1 => 'layout2', ], ]; $templateLayoutUtility = $this->getAccessibleMock(TemplateLayout::class, ['getTemplateLayoutsFromTsConfig']); - $templateLayoutUtility->expects($this->once())->method('getTemplateLayoutsFromTsConfig')->will($this->returnValue([])); + $templateLayoutUtility->expects(self::once())->method('getTemplateLayoutsFromTsConfig')->willReturn([]); $templateLayouts = $templateLayoutUtility->_call('getAvailableTemplateLayouts', 1); - $this->assertSame($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts'], $templateLayouts); + self::assertSame($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts'], $templateLayouts); } /** * @test - * - * @return void */ public function templatesFoundInPageTsConfig(): void { @@ -55,11 +51,11 @@ public function templatesFoundInPageTsConfig(): void $result = [ 0 => [ 0 => 'Layout 1', - 1 => 'layout1' + 1 => 'layout1', ], 1 => [ 0 => 'Layout 2', - 1 => 'layout2' + 1 => 'layout2', ], ]; @@ -67,15 +63,13 @@ public function templatesFoundInPageTsConfig(): void unset($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts']); $templateLayoutUtility = $this->getAccessibleMock(TemplateLayout::class, ['getTemplateLayoutsFromTsConfig']); - $templateLayoutUtility->expects($this->once())->method('getTemplateLayoutsFromTsConfig')->will($this->returnValue($tsConfigArray)); + $templateLayoutUtility->expects(self::once())->method('getTemplateLayoutsFromTsConfig')->willReturn($tsConfigArray); $templateLayouts = $templateLayoutUtility->_call('getAvailableTemplateLayouts', 1); - $this->assertSame($result, $templateLayouts); + self::assertSame($result, $templateLayouts); } /** * @test - * - * @return void */ public function templatesFoundInCombinedResources(): void { @@ -86,27 +80,27 @@ public function templatesFoundInCombinedResources(): void $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts'] = [ 0 => [ 0 => 'Layout 4', - 1 => 'layout4' + 1 => 'layout4', ], ]; $result = [ 0 => [ 0 => 'Layout 4', - 1 => 'layout4' + 1 => 'layout4', ], 1 => [ 0 => 'Layout 1', - 1 => 'layout1' + 1 => 'layout1', ], 2 => [ 0 => 'Layout 2', - 1 => 'layout2' + 1 => 'layout2', ], ]; $templateLayoutUtility = $this->getAccessibleMock(TemplateLayout::class, ['getTemplateLayoutsFromTsConfig']); - $templateLayoutUtility->expects($this->once())->method('getTemplateLayoutsFromTsConfig')->will($this->returnValue($tsConfigArray)); + $templateLayoutUtility->expects(self::once())->method('getTemplateLayoutsFromTsConfig')->willReturn($tsConfigArray); $templateLayouts = $templateLayoutUtility->_call('getAvailableTemplateLayouts', 1); - $this->assertSame($result, $templateLayouts); + self::assertSame($result, $templateLayouts); } } diff --git a/Tests/Unit/Utility/TypoScriptTest.php b/Tests/Unit/Utility/TypoScriptTest.php index b66acc712b..551fd0294c 100644 --- a/Tests/Unit/Utility/TypoScriptTest.php +++ b/Tests/Unit/Utility/TypoScriptTest.php @@ -1,19 +1,19 @@ override($base, $overload); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -43,56 +41,56 @@ public function overrideWorksDataProvider() 'basic' => [ [ 'value_1' => 'fo', - 'value_2' => '' + 'value_2' => '', ], [], [ 'value_1' => 'fo', - 'value_2' => '' - ] + 'value_2' => '', + ], ], 'simple' => [ [ 'value_1' => 'fo', - 'value_2' => '' + 'value_2' => '', ], [ 'settings' => [ 'value_2' => 'bar', - 'overrideFlexformSettingsIfEmpty' => 'value_2' - ] + 'overrideFlexformSettingsIfEmpty' => 'value_2', + ], ], [ 'value_1' => 'fo', - 'value_2' => 'bar' - ] + 'value_2' => 'bar', + ], ], 'simple2' => [ [ 'value_1' => 'fo', 'sub' => [ - 'sub_1' => 'xy' - ] + 'sub_1' => 'xy', + ], ], [ 'settings' => [ 'value_2' => 'bar', - 'overrideFlexformSettingsIfEmpty' => 'value_2' - ] + 'overrideFlexformSettingsIfEmpty' => 'value_2', + ], ], [ 'value_1' => 'fo', 'value_2' => 'bar', 'sub' => [ - 'sub_1' => 'xy' - ] - ] + 'sub_1' => 'xy', + ], + ], ], 'deep' => [ [ 'value_1' => 'fo', 'sub_1' => [ - 'sub_1a' => '' + 'sub_1a' => '', ], 'sub_2' => [ 'sub_2a' => 'xy', @@ -102,25 +100,25 @@ public function overrideWorksDataProvider() 'settings' => [ 'value_2' => 'bar', 'sub_1' => [ - 'sub_1a' => 'lorem' + 'sub_1a' => 'lorem', ], 'sub_2' => [ 'sub_2a' => 'xy', - 'sub_2b' => 'abc' + 'sub_2b' => 'abc', ], - 'overrideFlexformSettingsIfEmpty' => 'value_2, sub_1.sub_1a,sub_2.sub_2b' - ] + 'overrideFlexformSettingsIfEmpty' => 'value_2, sub_1.sub_1a,sub_2.sub_2b', + ], ], [ 'value_1' => 'fo', 'value_2' => 'bar', 'sub_1' => [ - 'sub_1a' => 'lorem' + 'sub_1a' => 'lorem', ], 'sub_2' => [ 'sub_2a' => 'xy', ], - ] + ], ], ]; } @@ -129,8 +127,6 @@ public function overrideWorksDataProvider() * @test * * @dataProvider correctValueIsReturnedDataProvider - * - * @return void */ public function correctValueIsReturned($path, $expected): void { @@ -141,15 +137,15 @@ public function correctValueIsReturned($path, $expected): void 'in_1' => 'value in 1', 'level_2' => [ 'level_3' => [ - 'in_3' => 'value in 3' - ] - ] - ] + 'in_3' => 'value in 3', + ], + ], + ], ]; $path = explode('.', $path); $result = $mockedUtility->_call('getValue', $in, $path); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -161,16 +157,16 @@ public function correctValueIsReturnedDataProvider() { return [ 'valueFoundInDeepLevel' => [ - 'level_1.level_2.level_3.in_3', 'value in 3' + 'level_1.level_2.level_3.in_3', 'value in 3', ], 'valueFoundInFirstLevel' => [ - 'level_1.in_1', 'value in 1' + 'level_1.in_1', 'value in 1', ], 'firstLevelNotFound' => [ - 'wrong.wronger.stillWrong', null + 'wrong.wronger.stillWrong', null, ], 'lastLevelNotFound' => [ - 'level_1.level_2.level_3.in_Nothing', null + 'level_1.level_2.level_3.in_Nothing', null, ], ]; } @@ -179,8 +175,6 @@ public function correctValueIsReturnedDataProvider() * @test * * @dataProvider correctValueIsSetDataProvider - * - * @return void */ public function correctValueIsSet($path, $newValue, $expected): void { @@ -191,15 +185,15 @@ public function correctValueIsSet($path, $newValue, $expected): void 'in_1' => 'value in 1', 'level_2' => [ 'level_3' => [ - 'in_3' => 'value in 3' - ] - ] - ] + 'in_3' => 'value in 3', + ], + ], + ], ]; $path = explode('.', $path); $result = $mockedUtility->_call('setValue', $in, $path, $newValue); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -218,11 +212,11 @@ public function correctValueIsSetDataProvider() 'in_1' => 'new value in 1', 'level_2' => [ 'level_3' => [ - 'in_3' => 'value in 3' - ] - ] - ] - ] + 'in_3' => 'value in 3', + ], + ], + ], + ], ], 'overrideValueDeep' => [ 'level_1.level_2.level_3.in_3', @@ -232,11 +226,11 @@ public function correctValueIsSetDataProvider() 'in_1' => 'value in 1', 'level_2' => [ 'level_3' => [ - 'in_3' => 'new value in 3' - ] - ] - ] - ] + 'in_3' => 'new value in 3', + ], + ], + ], + ], ], 'newValueDeep' => [ 'level_1.level_2.level_3.level_4.level_5.in_5', @@ -249,13 +243,13 @@ public function correctValueIsSetDataProvider() 'in_3' => 'value in 3', 'level_4' => [ 'level_5' => [ - 'in_5' => 'new value in 5' - ] - ] - ] - ] - ] - ] + 'in_5' => 'new value in 5', + ], + ], + ], + ], + ], + ], ], 'overrideArrayWithValue' => [ 'level_1.level_2', @@ -263,9 +257,9 @@ public function correctValueIsSetDataProvider() [ 'level_1' => [ 'in_1' => 'value in 1', - 'level_2' => 'new value as 2' - ] - ] + 'level_2' => 'new value as 2', + ], + ], ], ]; } diff --git a/Tests/Unit/Utility/ValidationTest.php b/Tests/Unit/Utility/ValidationTest.php index 5a3a50a68b..aa58a48a51 100644 --- a/Tests/Unit/Utility/ValidationTest.php +++ b/Tests/Unit/Utility/ValidationTest.php @@ -1,19 +1,19 @@ assertEquals($validation, $expected); + self::assertEquals($validation, $expected); } /** @@ -43,37 +41,37 @@ public function orderDataProvider(): array { return [ 'allowedOrdering' => [ - 'title,uid', true + 'title,uid', true, ], 'allowedOrderingWithSorting' => [ - 'title ASC, uid', true + 'title ASC, uid', true, ], 'allowedOrderingWithSorting2' => [ - 'title ASC, uid DESC', true + 'title ASC, uid DESC', true, ], 'allowedOrderingWithSorting3' => [ - 'title, uid desc,teaser', true + 'title, uid desc,teaser', true, ], 'allowedOrderingWithDotsAndSorting' => [ - 'categories.title DESC, uid ASC,author,teaser desc', true + 'categories.title DESC, uid ASC,author,teaser desc', true, ], 'nonAllowedField' => [ - 'title,teaserFo,uid', false + 'title,teaserFo,uid', false, ], 'nonAllowedSorting' => [ - 'title,teaser ASCx,uid', false + 'title,teaser ASCx,uid', false, ], 'nonAllowedDoubleSorting' => [ - 'title,teaser ASC DESC,uid', false + 'title,teaser ASC DESC,uid', false, ], 'nonAllowedDoubleFields' => [ - 'title teaser,uid', false + 'title teaser,uid', false, ], 'emptySorting' => [ - '', true + '', true, ], 'emptySorting2' => [ - ' ', true + ' ', true, ], ]; diff --git a/Tests/Unit/ViewHelpers/Be/IsCheckboxActiveViewhelperTest.php b/Tests/Unit/ViewHelpers/Be/IsCheckboxActiveViewhelperTest.php index 8846a55551..8984af9d31 100644 --- a/Tests/Unit/ViewHelpers/Be/IsCheckboxActiveViewhelperTest.php +++ b/Tests/Unit/ViewHelpers/Be/IsCheckboxActiveViewhelperTest.php @@ -1,19 +1,19 @@ setArguments([ 'id' => 10, - 'categories' => [5, 7, 10, 12] + 'categories' => [5, 7, 10, 12], ]); $actualResult = $viewHelper->render(); - $this->assertEquals(self::OK_RESULT, $actualResult); + self::assertEquals(self::OK_RESULT, $actualResult); } /** * @test - * - * @return void */ public function nonActiveCheckboxReturnsNothing(): void { $viewHelper = new IsCheckboxActiveViewHelper(); $viewHelper->setArguments([ 'id' => 8, - 'categories' => [5, 7, 10, 12] + 'categories' => [5, 7, 10, 12], ]); $actualResult = $viewHelper->render(); - $this->assertEquals('', $actualResult); + self::assertEquals('', $actualResult); } /** * @test - * - * @return void */ public function noCategoriesReturnNothing(): void { $viewHelper = new IsCheckboxActiveViewHelper(); - $this->assertEquals('', $viewHelper->render()); + self::assertEquals('', $viewHelper->render()); } } diff --git a/Tests/Unit/ViewHelpers/ExcludeDisplayedNewsViewHelperTest.php b/Tests/Unit/ViewHelpers/ExcludeDisplayedNewsViewHelperTest.php index e3baf3aeb3..3778ae2975 100644 --- a/Tests/Unit/ViewHelpers/ExcludeDisplayedNewsViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/ExcludeDisplayedNewsViewHelperTest.php @@ -1,13 +1,14 @@ setArguments(['newsItem' => $newsItem1]); $viewHelper->render(); - $this->assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123']); + self::assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123']); $newsItem1 = new News(); $newsItem1->_setProperty('uid', '123'); - $this->assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123']); + self::assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123']); $newsItem2 = new News(); $newsItem2->_setProperty('uid', '12'); $viewHelper->setArguments(['newsItem' => $newsItem2]); $viewHelper->render(); - $this->assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123', '12' => '12']); + self::assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123', '12' => '12']); $newsItem3 = new News(); $newsItem3->_setProperty('uid', '12'); $newsItem3->_setProperty('_localizedUid', '456'); $viewHelper->setArguments(['newsItem' => $newsItem3]); $viewHelper->render(); - $this->assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123', '12' => '12', '456' => '456']); + self::assertEquals($GLOBALS['EXT']['news']['alreadyDisplayed'], ['123' => '123', '12' => '12', '456' => '456']); } } diff --git a/Tests/Unit/ViewHelpers/Format/NothingViewHelperTest.php b/Tests/Unit/ViewHelpers/Format/NothingViewHelperTest.php index c82cdcfcc1..34fd2cb004 100644 --- a/Tests/Unit/ViewHelpers/Format/NothingViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Format/NothingViewHelperTest.php @@ -1,20 +1,19 @@ getAccessibleMock(NothingViewHelper::class, ['renderChildren']); - $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('whatever content')); + $viewHelper->expects(self::once())->method('renderChildren')->willReturn('whatever content'); $actualResult = $viewHelper->render(); - $this->assertEquals(null, $actualResult); + self::assertNull($actualResult); } } diff --git a/Tests/Unit/ViewHelpers/LinkViewHelperTest.php b/Tests/Unit/ViewHelpers/LinkViewHelperTest.php index c81f14a218..310549b608 100644 --- a/Tests/Unit/ViewHelpers/LinkViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/LinkViewHelperTest.php @@ -1,14 +1,14 @@ newsItem = new News(); - $this->mockedViewHelper = $this->getAccessibleMock(LinkViewHelper::class, ['init', 'renderChildren']); + $this->mockedViewHelper = $this->getAccessibleMock(LinkViewHelper::class, ['initializeContentObjectRenderer', 'renderChildren']); $this->mockedContentObjectRenderer = $this->getAccessibleMock(ContentObjectRenderer::class, ['typoLink_URL', 'typoLink']); $pluginSettings = $this->getAccessibleMock(SettingsService::class, ['getSettings']); $tag = $this->getAccessibleMock(TagBuilder::class, ['addAttribute', 'setContent', 'render']); @@ -49,15 +49,13 @@ public function setup(): void /** * @test - * - * @return void */ public function internalPageIsUsed(): void { $url = '123'; $result = ['parameter' => $url]; - $this->mockedContentObjectRenderer->expects($this->once())->method('typoLink_URL')->with($result); + $this->mockedContentObjectRenderer->expects(self::once())->method('typoLink_URL')->with($result); $this->newsItem->setType(1); $this->newsItem->setInternalurl($url); @@ -67,15 +65,13 @@ public function internalPageIsUsed(): void /** * @test - * - * @return void */ public function externalUrlIsUsed(): void { $url = 'http://www.typo3.org'; $result = ['parameter' => $url]; - $this->mockedContentObjectRenderer->expects($this->once())->method('typoLink_URL')->with($result); + $this->mockedContentObjectRenderer->expects(self::once())->method('typoLink_URL')->with($result); $this->newsItem->setType(2); $this->newsItem->setExternalurl($url); @@ -85,8 +81,6 @@ public function externalUrlIsUsed(): void /** * @test - * - * @return void */ public function humanReadAbleDateIsAddedToConfiguration(): void { @@ -102,20 +96,18 @@ public function humanReadAbleDateIsAddedToConfiguration(): void 'day' => 'j', 'month' => 'n', 'year' => 'Y', - ] - ] + ], + ], ]; $configuration = []; $expected = '&tx_news_pi1[news]=123&tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[day]=16&tx_news_pi1[month]=5&tx_news_pi1[year]=2014'; $result = $this->mockedViewHelper->_call('getLinkToNewsItem', $newsItem, $tsSettings, $configuration); - $this->assertEquals($expected, $result['additionalParams']); + self::assertEquals($expected, $result['additionalParams']); } /** * @test - * - * @return void */ public function getDetailPidFromCategoriesReturnsCorrectValue(): void { @@ -138,22 +130,20 @@ public function getDetailPidFromCategoriesReturnsCorrectValue(): void $newsItem->setCategories($categories); $result = $viewHelper->_call('getDetailPidFromCategories', [], $newsItem); - $this->assertEquals(123, $result); + self::assertEquals(123, $result); } /** * @test * * @dataProvider getDetailPidFromDefaultDetailPidReturnsCorrectValueDataProvider - * - * @return void */ public function getDetailPidFromDefaultDetailPidReturnsCorrectValue($settings, $expected): void { $viewHelper = $this->getAccessibleMock(LinkViewHelper::class, ['dummy']); $result = $viewHelper->_call('getDetailPidFromDefaultDetailPid', $settings, null); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -175,15 +165,13 @@ public function getDetailPidFromDefaultDetailPidReturnsCorrectValueDataProvider( * @test * * @dataProvider getDetailPidFromFlexformReturnsCorrectValueDataProvider - * - * @return void */ public function getDetailPidFromFlexformReturnsCorrectValue($settings, $expected): void { $viewHelper = $this->getAccessibleMock(LinkViewHelper::class, ['dummy']); $result = $viewHelper->_call('getDetailPidFromFlexform', $settings, null); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } public function getDetailPidFromFlexformReturnsCorrectValueDataProvider(): array @@ -198,8 +186,6 @@ public function getDetailPidFromFlexformReturnsCorrectValueDataProvider(): array /** * @test - * - * @return void */ public function noNewsReturnsChildren(): void { @@ -209,13 +195,13 @@ public function noNewsReturnsChildren(): void $viewHelper->setArguments([ 'newsItem' => null, 'settings' => [ - 'useStdWrap' => false + 'useStdWrap' => false, ], 'configuration' => [], 'uriOnly' => false, - 'content' => '' + 'content' => '', ]); $result = $viewHelper->_call('render'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } } diff --git a/Tests/Unit/ViewHelpers/PaginateBodytextViewHelperTest.php b/Tests/Unit/ViewHelpers/PaginateBodytextViewHelperTest.php index b5e1537b38..a8f4b521da 100644 --- a/Tests/Unit/ViewHelpers/PaginateBodytextViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/PaginateBodytextViewHelperTest.php @@ -1,14 +1,14 @@ getAccessibleMock(PaginateBodytextViewHelper::class, ['dummy']); $result = $mockTemplateParser->_call('isClosingTag', $tag); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } /** @@ -42,10 +40,10 @@ public function givenTagIsAClosingTagDataProvider(): array { return [ 'working example 1' => [ - '
', true + '', true, ], 'working example 2' => [ - '
', false + '
', false, ], ]; } @@ -56,14 +54,12 @@ public function givenTagIsAClosingTagDataProvider(): array * @test * * @dataProvider givenTagIsSelfClosingTagDataProvider - * - * @return void */ public function givenTagIsSelfClosingTag($tag, $expectedResult): void { $mockTemplateParser = $this->getAccessibleMock(PaginateBodytextViewHelper::class, ['dummy']); $result = $mockTemplateParser->_call('isSelfClosingTag', $tag); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } /** @@ -75,10 +71,10 @@ public function givenTagIsSelfClosingTagDataProvider(): array { return [ 'working example 1' => [ - '
', true + '
', true, ], 'working example 2' => [ - '
', false + '
', false, ], ]; } @@ -89,14 +85,12 @@ public function givenTagIsSelfClosingTagDataProvider(): array * @test * * @dataProvider givenTagIsAnOpeningTagDataProvider - * - * @return void */ public function givenTagIsAnOpeningTag($tag, $expectedResult): void { $mockTemplateParser = $this->getAccessibleMock(PaginateBodytextViewHelper::class, ['dummy']); $result = $mockTemplateParser->_call('isOpeningTag', $tag); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } /** @@ -110,7 +104,7 @@ public function givenTagIsAnOpeningTagDataProvider(): array ['
', true], ['
', false], ['
', false], - ['
', false] + ['
', false], ]; } @@ -120,14 +114,12 @@ public function givenTagIsAnOpeningTagDataProvider(): array * @test * * @dataProvider extractTagReturnsCorrectOneDataProvider - * - * @return void */ public function extractTagReturnsCorrectOne($tag, $expectedResult): void { $mockTemplateParser = $this->getAccessibleMock(PaginateBodytextViewHelper::class, ['dummy']); $result = $mockTemplateParser->_call('extractTag', $tag); - $this->assertEquals($expectedResult, $result, sprintf('"%s" (%s) : "%s" (%s)', $tag, strlen($tag), $expectedResult, strlen($expectedResult))); + self::assertEquals($expectedResult, $result, sprintf('"%s" (%s) : "%s" (%s)', $tag, strlen($tag), $expectedResult, strlen($expectedResult))); } /** diff --git a/Tests/Unit/ViewHelpers/SimplePrevNextViewHelperTest.php b/Tests/Unit/ViewHelpers/SimplePrevNextViewHelperTest.php index 713b48dbfe..f3803e8450 100644 --- a/Tests/Unit/ViewHelpers/SimplePrevNextViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/SimplePrevNextViewHelperTest.php @@ -1,17 +1,17 @@ viewHelper->expects($this->any())->method('getRawRecord')->withAnyParameters()->will($this->returnValue(null)); + $this->viewHelper->expects(self::any())->method('getRawRecord')->withAnyParameters()->willReturn(null); $out = $this->viewHelper->_call('getObject', 0); - $this->assertEquals($out, null); + self::assertEquals($out, null); } /** * @test - * - * @return void */ public function queryResultWillReturnCorrectOutputForAllLinks(): void { @@ -54,13 +50,11 @@ public function queryResultWillReturnCorrectOutputForAllLinks(): void $exp = ['prev' => 123, 'next' => 789]; $viewHelper->expects(self::exactly(2))->method('getObject')->willReturnOnConsecutiveCalls(123, 789); $out = $viewHelper->_call('mapResultToObjects', $in); - $this->assertEquals($out, $exp); + self::assertEquals($out, $exp); } /** * @test - * - * @return void */ public function queryResultWillReturnCorrectOutputFor2Links(): void { @@ -72,13 +66,11 @@ public function queryResultWillReturnCorrectOutputFor2Links(): void $exp = ['prev' => 147]; $viewHelper->expects(self::exactly(1))->method('getObject')->willReturnOnConsecutiveCalls(147); $out = $viewHelper->_call('mapResultToObjects', $in); - $this->assertEquals($out, $exp); + self::assertEquals($out, $exp); } /** * @test - * - * @return void */ public function queryResultWillReturnCorrectOutputFor1Link(): void { @@ -90,6 +82,6 @@ public function queryResultWillReturnCorrectOutputFor1Link(): void $exp = ['next' => 369]; $viewHelper->expects(self::exactly(1))->method('getObject')->willReturnOnConsecutiveCalls(369); $out = $viewHelper->_call('mapResultToObjects', $in); - $this->assertEquals($out, $exp); + self::assertEquals($out, $exp); } } diff --git a/Tests/Unit/ViewHelpers/TargetLinkViewHelperTest.php b/Tests/Unit/ViewHelpers/TargetLinkViewHelperTest.php index 5fbebcbec3..19de3ff440 100644 --- a/Tests/Unit/ViewHelpers/TargetLinkViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/TargetLinkViewHelperTest.php @@ -1,13 +1,14 @@ getPreparedInstance(); - $this->assertInstanceOf(TargetLinkViewHelper::class, $instance); + self::assertInstanceOf(TargetLinkViewHelper::class, $instance); } /** @@ -44,8 +43,6 @@ public function canCreateViewHelperClassInstance(): void * @test * * @dataProvider correctTargetIsReturnedDataProvider - * - * @return void */ public function correctTargetIsReturned($link, $expectedResult): void { @@ -55,7 +52,7 @@ public function correctTargetIsReturned($link, $expectedResult): void 'link' => $link, ]); - $this->assertEquals($viewHelper->render(), $expectedResult); + self::assertEquals($viewHelper->render(), $expectedResult); } /** @@ -67,19 +64,19 @@ public function correctTargetIsReturnedDataProvider() { return [ 'noTargetSetAndUrlDefined' => [ - 'www.typo3.org', '' + 'www.typo3.org', '', ], 'noTargetSetAndIdDefined' => [ - '123', '' + '123', '', ], 'IdAndTargetDefined' => [ - '123 _blank', '_blank' + '123 _blank', '_blank', ], 'UrlAndPopupDefined' => [ - 'www.typo3.org 300x400', '' + 'www.typo3.org 300x400', '', ], 'ComplexExample' => [ - 'www.typo3.org _fo my-class', '_fo' + 'www.typo3.org _fo my-class', '_fo', ], ]; diff --git a/composer.json b/composer.json index 3da79df234..f268083c41 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "GPL-2.0-or-later" ], "require": { - "php": ">= 7.4 < 8.2", - "typo3/cms-core": "^10.4 || ^11" + "typo3/cms-core": "^11.5.24 || ^12", + "php": ">= 7.4 < 8.3" }, "conflict": { "symfony/finder": "2.7.44 || 2.8.37 || 3.4.7 || 4.0.7" @@ -37,8 +37,13 @@ "georgringer/numbered-pagination": "Improved pagination API" }, "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "typo3/cms-install": "^10.4 || ^11" + "typo3/cms-composer-installers": "^3.1.3 || 4.0.0-RC1 || ^5.0", + "sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": "^0.0.1", + "typo3/testing-framework": "~7.0@dev", + "phpunit/phpunit": "^9", + "typo3/coding-standards": "^0.5.3", + "friendsofphp/php-cs-fixer": "^3.13.0", + "webmozart/assert": "^1.11.0" }, "autoload": { "psr-4": { @@ -57,11 +62,14 @@ "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin", "allow-plugins": { + "sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true, "typo3/class-alias-loader": true, "typo3/cms-composer-installers": true } }, "scripts": { + "cs": "php ./.Build/bin/php-cs-fixer fix --dry-run -v --config ./Build/php-cs-fixer/php-cs-fixer.php ./", + "csfix": "php ./.Build/bin/php-cs-fixer fix -v --config ./Build/php-cs-fixer/php-cs-fixer.php ./", "post-autoload-dump": [ "TYPO3\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" ] diff --git a/ext_conf_template.txt b/ext_conf_template.txt index c11cc26ea9..0cd9775ee2 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -12,9 +12,6 @@ rteForTeaser = 0 # cat=records/enable/110; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.contentElementRelation contentElementRelation = 1 -# cat=records/enable/111; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.contentElementPreview -contentElementPreview = 1 - # cat=records/enable/120; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.manualSorting manualSorting = 0 @@ -30,9 +27,6 @@ dateTimeNotRequired = 0 # cat=records/enable/2; type=options[LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.archiveDate.date=date,LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.archiveDate.datetime=datetime]; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.archiveDate archiveDate = date -# cat=records/enable/150; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.mediaPreview -mediaPreview = false - # cat=records/enable/153; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.advancedMediaPreview advancedMediaPreview = 1 @@ -47,9 +41,6 @@ showAdministrationModule = 1 # cat=backend module/enable/12; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.hidePageTreeForAdministrationModule hidePageTreeForAdministrationModule = 0 -# cat=import module/enable/20; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.showImporter -showImporter = 0 - # cat=import module/enable/21; type=int; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.storageUidImporter storageUidImporter = 1 diff --git a/ext_emconf.php b/ext_emconf.php index a1e396798e..8fa4873f64 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -11,14 +11,14 @@ 'version' => '10.0.3', 'constraints' => [ 'depends' => [ - 'php' => '7.4.0-8.1.99', - 'typo3' => '10.4.13-11.9.99', + 'typo3' => '11.5.19-12.9.99', + 'php' => '7.4.0-8.2.99', ], 'conflicts' => [], 'suggests' => [ 'rx_shariff' => '12.0.0-14.99.99', 'news_tagsuggest' => '1.0.0-1.99.99', - 'numbered_pagination' => '1.0.1-1.99.99' + 'numbered_pagination' => '1.0.1-1.99.99', ], ], ]; diff --git a/ext_localconf.php b/ext_localconf.php index 6a8107bcd4..17ccacf3d0 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,24 +1,94 @@ 'list,detail,selectedList,dateMenu,searchForm,searchResult', - \GeorgRinger\News\Controller\CategoryController::class => 'list', - \GeorgRinger\News\Controller\TagController::class => 'list', + \GeorgRinger\News\Controller\NewsController::class => 'list,detail', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'NewsListSticky', + [ + \GeorgRinger\News\Controller\NewsController::class => 'list', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'NewsDetail', + [ + \GeorgRinger\News\Controller\NewsController::class => 'detail', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'NewsSelectedList', + [ + \GeorgRinger\News\Controller\NewsController::class => 'selectedList', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'NewsDateMenu', + [ + \GeorgRinger\News\Controller\NewsController::class => 'dateMenu', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'NewsSearchForm', + [ + \GeorgRinger\News\Controller\NewsController::class => 'searchForm', + ], + [ + \GeorgRinger\News\Controller\NewsController::class => 'searchForm', + ], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'NewsSearchResult', + [ + \GeorgRinger\News\Controller\NewsController::class => 'searchResult', ], [ - \GeorgRinger\News\Controller\NewsController::class => 'searchForm,searchResult', - ] + \GeorgRinger\News\Controller\NewsController::class => 'searchResult', + ], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); - // Page module hook - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['news' . '_pi1']['news'] = - \GeorgRinger\News\Hooks\PageLayoutView::class . '->getExtensionSummary'; + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'CategoryList', + [ + \GeorgRinger\News\Controller\CategoryController::class => 'list', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'News', + 'TagList', + [ + \GeorgRinger\News\Controller\TagController::class => 'list', + ], + [], + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['news_clearcache'] = \GeorgRinger\News\Hooks\DataHandlerHook::class . '->clearCachePostProc'; @@ -31,35 +101,27 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['news'] = \GeorgRinger\News\Hooks\DataHandlerHook::class; - // Modify flexform values - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['flexParsing']['news'] - = \GeorgRinger\News\Hooks\FlexformHook::class; - - // Modify flexform fields since core 8.5 via formEngine: Inject a data provider between TcaFlexPrepare and TcaFlexProcess - $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][\GeorgRinger\News\Backend\FormDataProvider\NewsFlexFormManipulation::class] = [ - 'depends' => [ - \TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare::class, - ], - 'before' => [ - \TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess::class, - ], - ]; +// // Modify flexform fields since core 8.5 via formEngine: Inject a data provider between TcaFlexPrepare and TcaFlexProcess +// $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][\GeorgRinger\News\Backend\FormDataProvider\NewsFlexFormManipulation::class] = [ +// 'depends' => [ +// \TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare::class, +// ], +// 'before' => [ +// \TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess::class, +// ], +// ]; // Hide content elements in list module & filter in administration module $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class]['modifyQuery']['ext:news'] = \GeorgRinger\News\Hooks\Backend\RecordListQueryHook::class; // Hide content elements in page module + // @extensionScannerIgnoreLine $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Backend\View\PageLayoutView::class]['modifyQuery']['ext:news'] = \GeorgRinger\News\Hooks\Backend\PageViewQueryHook::class; // Inline records hook - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook']['news'] = - \GeorgRinger\News\Hooks\InlineElementHook::class; - - // Xclass InlineRecordContainer - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Backend\Form\Container\InlineRecordContainer::class] = [ - 'className' => \GeorgRinger\News\Xclass\InlineRecordContainerForNews::class, - ]; + // @extensionScannerIgnoreLine + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook']['news'] = \GeorgRinger\News\Hooks\InlineElementHook::class; /* =========================================================================== Custom cache, done with the caching framework @@ -102,7 +164,7 @@ ], 'options' => [ 'defaultLifetime' => 0, - ] + ], ]; if (class_exists(\GeorgRinger\News\Utility\ClassLoader::class)) { @@ -114,45 +176,29 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][\GeorgRinger\News\Backend\FormDataProvider\NewsRowInitializeNew::class] = [ 'depends' => [ \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew::class, - ] + ], ]; - if (TYPO3_MODE === 'BE') { - $icons = [ - 'apps-pagetree-folder-contains-news' => 'ext-news-folder-tree.svg', - 'apps-pagetree-page-contains-news' => 'ext-news-page-tree.svg', - 'ext-news-wizard-icon' => 'plugin_wizard.svg', - 'ext-news-type-default' => 'news_domain_model_news.svg', - 'ext-news-type-internal' => 'news_domain_model_news_internal.svg', - 'ext-news-type-external' => 'news_domain_model_news_external.svg', - 'ext-news-tag' => 'news_domain_model_tag.svg', - 'ext-news-link' => 'news_domain_model_link.svg', - 'ext-news-donation' => 'donation.svg', - 'ext-news-paypal' => 'donation_paypal.svg', - 'ext-news-patreon' => 'donation_patreon.svg', - 'ext-news-amazon' => 'donation_amazon.svg', - 'ext-news-doublecheck' => 'double_check.svg', - ]; - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); - foreach ($icons as $identifier => $path) { - if (!$iconRegistry->isRegistered($identifier)) { - $iconRegistry->registerIcon( - $identifier, - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - ['source' => 'EXT:news/Resources/Public/Icons/' . $path] - ); - } - } - } - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['realurlAliasNewsSlug'] = \GeorgRinger\News\Updates\RealurlAliasNewsSlugUpdater::class; // Recommended before 'newsSlug' $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['newsSlug'] = \GeorgRinger\News\Updates\NewsSlugUpdater::class; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysCategorySlugs'] = \GeorgRinger\News\Updates\PopulateCategorySlugs::class; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsTagSlugs'] = \GeorgRinger\News\Updates\PopulateTagSlugs::class; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsRelatedLinkIntegerDefault'] = \GeorgRinger\News\Updates\RelatedLinkIntegerDefault::class; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsTitleFieldDefault'] = \GeorgRinger\News\Updates\TitleFieldDefault::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsPluginUpdater'] = \GeorgRinger\News\Updates\PluginUpdater::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsPluginPermissionUpdater'] = \GeorgRinger\News\Updates\PluginPermissionUpdater::class; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(trim(' + plugin { + tx_news_newsliststicky.view.pluginNamespace = tx_news_pi1 + tx_news_newsdetail.view.pluginNamespace = tx_news_pi1 + tx_news_newsselectedlist.view.pluginNamespace = tx_news_pi1 + tx_news_newsdatemenu.view.pluginNamespace = tx_news_pi1 + tx_news_categorylist.view.pluginNamespace = tx_news_pi1 + tx_news_newssearchform.view.pluginNamespace = tx_news_pi1 + tx_news_newssearchresult.view.pluginNamespace = tx_news_pi1 + tx_news_taglist.view.pluginNamespace = tx_news_pi1 + } config.pageTitleProviders { news { provider = GeorgRinger\News\Seo\NewsTitleProvider @@ -170,11 +216,15 @@ 'tx_news_pi1[overwriteDemand][categories]', 'tx_news_pi1[overwriteDemand][year]', 'tx_news_pi1[overwriteDemand][month]', - 'tx_news_pi1[overwriteDemand][day]' + 'tx_news_pi1[overwriteDemand][day]', ] ); } + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Extbase\Service\ExtensionService::class] = [ + 'className' => \GeorgRinger\News\Xclass\ExtensionServiceXclassed::class, + ]; + // Add routing features $GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['NewsCategory'] = \GeorgRinger\News\Routing\NewsAliasMapper::class; $GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['NewsTag'] = \GeorgRinger\News\Routing\NewsAliasMapper::class; diff --git a/ext_tables.php b/ext_tables.php index 075ef17919..e1eb6deb94 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,84 +1,74 @@ getMajorVersion() < 12) { + // CSH - context sensitive help + foreach (['news', 'tag', 'link'] as $table) { + // @extensionScannerIgnoreLine + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_news_domain_model_' . $table); - // CSH - context sensitive help - foreach (['news', 'media', 'tag', 'link'] as $table) { - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_news_domain_model_' . $table); + // @extensionScannerIgnoreLine + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr( + 'tx_news_domain_model_' . $table, + 'EXT:news/Resources/Private/Language/locallang_csh_' . $table . '.xlf' + ); + } + + // @extensionScannerIgnoreLine \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr( - 'tx_news_domain_model_' . $table, - 'EXT:news/Resources/Private/Language/locallang_csh_' . $table . '.xlf' + 'tt_content.pi_flexform.news_pi1.list', + 'EXT:news/Resources/Private/Language/locallang_csh_flexforms.xlf' ); - } - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr( - 'tt_content.pi_flexform.news_pi1.list', - 'EXT:news/Resources/Private/Language/locallang_csh_flexforms.xlf' - ); - - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr( - 'sys_file_reference', - 'EXT:news/Resources/Private/Language/locallang_csh_sys_file_reference.xlf' - ); + // @extensionScannerIgnoreLine + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr( + 'sys_file_reference', + 'EXT:news/Resources/Private/Language/locallang_csh_sys_file_reference.xlf' + ); + } $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\GeorgRinger\News\Domain\Model\Dto\EmConfiguration::class); - if (TYPO3_MODE === 'BE') { - // Extend user settings - $GLOBALS['TYPO3_USER_SETTINGS']['columns']['newsoverlay'] = [ - 'label' => 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:usersettings.overlay', - 'type' => 'select', - 'itemsProcFunc' => \GeorgRinger\News\Hooks\ItemsProcFunc::class . '->user_categoryOverlay', - ]; - if (!isset($GLOBALS['TYPO3_USER_SETTINGS']['showitem'])) { - $GLOBALS['TYPO3_USER_SETTINGS']['showitem'] = ''; - } - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings('--div--;LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pi1_title,newsoverlay'); + // Extend user settings + $GLOBALS['TYPO3_USER_SETTINGS']['columns']['newsoverlay'] = [ + 'label' => 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:usersettings.overlay', + 'type' => 'select', + 'itemsProcFunc' => \GeorgRinger\News\Hooks\ItemsProcFunc::class . '->user_categoryOverlay', + ]; + if (!isset($GLOBALS['TYPO3_USER_SETTINGS']['showitem'])) { + $GLOBALS['TYPO3_USER_SETTINGS']['showitem'] = ''; + } + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings('--div--;LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pi1_title,newsoverlay'); - // Add tables to livesearch (e.g. "#news:fo" or "#newscat:fo") - $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['news'] = 'tx_news_domain_model_news'; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['newstag'] = 'tx_news_domain_model_tag'; + // Add tables to livesearch (e.g. "#news:fo" or "#newscat:fo") + $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['news'] = 'tx_news_domain_model_news'; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['newstag'] = 'tx_news_domain_model_tag'; - /* =========================================================================== - Register BE-Modules - =========================================================================== */ - if ($configuration->getShowImporter()) { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( - 'News', - 'system', - 'tx_news_m1', - '', - [\GeorgRinger\News\Controller\ImportController::class => 'index, runJob, jobInfo'], - [ - 'access' => 'user,group', - 'icon' => 'EXT:news/Resources/Public/Icons/module_import.svg', - 'labels' => 'LLL:EXT:news/Resources/Private/Language/locallang_mod.xlf', - ] - ); - } - - /* =========================================================================== - Register BE-Module for Administration - =========================================================================== */ - if ($configuration->getShowAdministrationModule()) { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( - 'News', - 'web', - 'administration', - '', - [\GeorgRinger\News\Controller\AdministrationController::class => 'index,newNews,newCategory,newTag,newsPidListing,donate'], - [ - 'access' => 'user,group', - 'icon' => 'EXT:news/Resources/Public/Icons/module_administration.svg', - 'labels' => 'LLL:EXT:news/Resources/Private/Language/locallang_modadministration.xlf', - 'navigationComponentId' => $configuration->getHidePageTreeForAdministrationModule() ? '' : 'TYPO3/CMS/Backend/PageTree/PageTreeElement', - 'inheritNavigationComponentFromMainModule' => false, - 'path' => '/module/web/NewsAdministration' - ] - ); - } + /* =========================================================================== + Register BE-Module for Administration + =========================================================================== */ + if ($configuration->getShowAdministrationModule()) { + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'News', + 'web', + 'administration', + '', + [\GeorgRinger\News\Controller\AdministrationController::class => 'index,newNews,newCategory,newTag,newsPidListing,donate'], + [ + 'access' => 'user,group', + 'icon' => 'EXT:news/Resources/Public/Icons/module_administration.svg', + 'labels' => 'LLL:EXT:news/Resources/Private/Language/locallang_modadministration.xlf', + 'navigationComponentId' => $configuration->getHidePageTreeForAdministrationModule() ? '' : 'TYPO3/CMS/Backend/PageTree/PageTreeElement', + 'inheritNavigationComponentFromMainModule' => false, + 'path' => '/module/web/NewsAdministration/', + ] + ); } /* =========================================================================== diff --git a/ext_tables.sql b/ext_tables.sql index 53685fa4ca..c9ce2854f6 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -7,16 +7,6 @@ CREATE TABLE tx_news_domain_model_news ( tstamp int(11) DEFAULT '0' NOT NULL, crdate int(11) DEFAULT '0' NOT NULL, cruser_id int(11) DEFAULT '0' NOT NULL, - t3ver_oid int(11) DEFAULT '0' NOT NULL, - t3ver_id int(11) DEFAULT '0' NOT NULL, - t3ver_wsid int(11) DEFAULT '0' NOT NULL, - t3ver_label varchar(30) DEFAULT '' NOT NULL, - t3ver_state tinyint(4) DEFAULT '0' NOT NULL, - t3ver_stage tinyint(4) DEFAULT '0' NOT NULL, - t3ver_count int(11) DEFAULT '0' NOT NULL, - t3ver_tstamp int(11) DEFAULT '0' NOT NULL, - t3ver_move_id int(11) DEFAULT '0' NOT NULL, - t3_origuid int(11) DEFAULT '0' NOT NULL, editlock tinyint(4) DEFAULT '0' NOT NULL, sys_language_uid int(11) DEFAULT '0' NOT NULL, l10n_parent int(11) DEFAULT '0' NOT NULL, @@ -129,16 +119,6 @@ CREATE TABLE tx_news_domain_model_link ( l10n_parent int(11) DEFAULT '0' NOT NULL, l10n_diffsource mediumtext, l10n_source int(11) DEFAULT '0' NOT NULL, - t3ver_oid int(11) DEFAULT '0' NOT NULL, - t3ver_id int(11) DEFAULT '0' NOT NULL, - t3_origuid int(11) DEFAULT '0' NOT NULL, - t3ver_wsid int(11) DEFAULT '0' NOT NULL, - t3ver_label varchar(30) DEFAULT '' NOT NULL, - t3ver_state tinyint(4) DEFAULT '0' NOT NULL, - t3ver_stage tinyint(4) DEFAULT '0' NOT NULL, - t3ver_count int(11) DEFAULT '0' NOT NULL, - t3ver_tstamp int(11) DEFAULT '0' NOT NULL, - t3ver_move_id int(11) DEFAULT '0' NOT NULL, sorting int(10) DEFAULT '0' NOT NULL, deleted tinyint(4) DEFAULT '0' NOT NULL, hidden tinyint(4) DEFAULT '0' NOT NULL, @@ -167,16 +147,6 @@ CREATE TABLE tx_news_domain_model_tag ( l10n_parent int(11) DEFAULT '0' NOT NULL, l10n_diffsource mediumtext, l10n_source int(11) DEFAULT '0' NOT NULL, - t3ver_oid int(11) DEFAULT '0' NOT NULL, - t3ver_id int(11) DEFAULT '0' NOT NULL, - t3_origuid int(11) DEFAULT '0' NOT NULL, - t3ver_wsid int(11) DEFAULT '0' NOT NULL, - t3ver_label varchar(30) DEFAULT '' NOT NULL, - t3ver_state tinyint(4) DEFAULT '0' NOT NULL, - t3ver_stage tinyint(4) DEFAULT '0' NOT NULL, - t3ver_count int(11) DEFAULT '0' NOT NULL, - t3ver_tstamp int(11) DEFAULT '0' NOT NULL, - t3ver_move_id int(11) DEFAULT '0' NOT NULL, title tinytext, slug varchar(2048), seo_title varchar(255) NOT NULL DEFAULT '',