diff --git a/.ddev/config.yaml b/.ddev/config.yaml new file mode 100644 index 0000000..c6d022d --- /dev/null +++ b/.ddev/config.yaml @@ -0,0 +1,283 @@ +name: tt-news-v11 +type: typo3 +docroot: .Build/Web/ +php_version: "8.1" +webserver_type: apache-fpm +router_http_port: "80" +router_https_port: "443" +xdebug_enabled: false +additional_hostnames: [] +additional_fqdns: [] +database: + type: mariadb + version: "10.5" +hooks: + post-start: + - exec: composer i +use_dns_when_possible: true +timezone: Europe/Berlin +composer_version: "2" +web_environment: [] + +# Key features of DDEV's config.yaml: + +# name: # Name of the project, automatically provides +# http://projectname.ddev.site and https://projectname.ddev.site + +# type: # backdrop, craftcms, django4, drupal6/7/8/9/10, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress +# See https://ddev.readthedocs.io/en/latest/users/quickstart/ for more +# information on the different project types + +# docroot: # Relative path to the directory containing index.php. + +# php_version: "8.1" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3" + +# You can explicitly specify the webimage but this +# is not recommended, as the images are often closely tied to DDEV's' behavior, +# so this can break upgrades. + +# webimage: # nginx/php docker image. + +# database: +# type: # mysql, mariadb, postgres +# version: # database version, like "10.4" or "8.0" +# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0 +# PostgreSQL versions can be 9-16. + +# router_http_port: # Port to be used for http (defaults to global configuration, usually 80) +# router_https_port: # Port for https (defaults to global configuration, usually 443) + +# xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart" +# Note that for most people the commands +# "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better, +# as leaving Xdebug enabled all the time is a big performance hit. + +# xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart" +# Note that for most people the commands +# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better, +# as leaving Xhprof enabled all the time is a big performance hit. + +# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn + +# timezone: Europe/Berlin +# This is the timezone used in the containers and by PHP; +# it can be set to any valid timezone, +# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +# For example Europe/Dublin or MST7MDT + +# composer_root: +# Relative path to the Composer root directory from the project root. This is +# the directory which contains the composer.json and where all Composer related +# commands are executed. + +# composer_version: "2" +# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1 +# to use the latest major version available at the time your container is built. +# It is also possible to use each other Composer version channel. This includes: +# - 2.2 (latest Composer LTS version) +# - stable +# - preview +# - snapshot +# Alternatively, an explicit Composer version may be specified, for example "2.2.18". +# To reinstall Composer after the image was built, run "ddev debug refresh". + +# nodejs_version: "18" +# change from the default system Node.js version to any other version. +# Numeric version numbers can be complete (i.e. 18.15.0) or +# incomplete (18, 17.2, 16). 'lts' and 'latest' can be used as well along with +# other named releases. +# see https://www.npmjs.com/package/n#specifying-nodejs-versions +# Note that you can continue using 'ddev nvm' or nvm inside the web container +# to change the project's installed node version if you need to. + +# additional_hostnames: +# - somename +# - someothername +# would provide http and https URLs for "somename.ddev.site" +# and "someothername.ddev.site". + +# additional_fqdns: +# - example.com +# - sub1.example.com +# would provide http and https URLs for "example.com" and "sub1.example.com" +# Please take care with this because it can cause great confusion. + +# upload_dirs: "custom/upload/dir" +# +# upload_dirs: +# - custom/upload/dir +# - ../private +# +# would set the destination paths for ddev import-files to /custom/upload/dir +# When Mutagen is enabled this path is bind-mounted so that all the files +# in the upload_dirs don't have to be synced into Mutagen. + +# disable_upload_dirs_warning: false +# If true, turns off the normal warning that says +# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set" + +# ddev_version_constraint: "" +# Example: +# ddev_version_constraint: ">= 1.22.4" +# This will enforce that the running ddev version is within this constraint. +# See https://github.com/Masterminds/semver#checking-version-constraints for +# supported constraint formats + +# working_dir: +# web: /var/www/html +# db: /home +# would set the default working directory for the web and db services. +# These values specify the destination directory for ddev ssh and the +# directory in which commands passed into ddev exec are run. + +# omit_containers: [db, ddev-ssh-agent] +# Currently only these containers are supported. Some containers can also be +# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit +# the "db" container, several standard features of DDEV that access the +# database container will be unusable. In the global configuration it is also +# possible to omit ddev-router, but not here. + +# performance_mode: "global" +# DDEV offers performance optimization strategies to improve the filesystem +# performance depending on your host system. Should be configured globally. +# +# If set, will override the global config. Possible values are: +# - "global": uses the value from the global config. +# - "none": disables performance optimization for this project. +# - "mutagen": enables Mutagen for this project. +# - "nfs": enables NFS for this project. +# +# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs +# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen + +# fail_on_hook_fail: False +# Decide whether 'ddev start' should be interrupted by a failing hook + +# host_https_port: "59002" +# The host port binding for https can be explicitly specified. It is +# dynamic unless otherwise specified. +# This is not used by most people, most people use the *router* instead +# of the localhost port. + +# host_webserver_port: "59001" +# The host port binding for the ddev-webserver can be explicitly specified. It is +# dynamic unless otherwise specified. +# This is not used by most people, most people use the *router* instead +# of the localhost port. + +# host_db_port: "59002" +# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic +# unless explicitly specified. + +# mailpit_http_port: "8025" +# mailpit_https_port: "8026" +# The Mailpit ports can be changed from the default 8025 and 8026 + +# host_mailpit_port: "8025" +# The mailpit port is not normally bound on the host at all, instead being routed +# through ddev-router, but it can be bound directly to localhost if specified here. + +# webimage_extra_packages: [php7.4-tidy, php-bcmath] +# Extra Debian packages that are needed in the webimage can be added here + +# dbimage_extra_packages: [telnet,netcat] +# Extra Debian packages that are needed in the dbimage can be added here + +# use_dns_when_possible: true +# If the host has internet access and the domain configured can +# successfully be looked up, DNS will be used for hostname resolution +# instead of editing /etc/hosts +# Defaults to true + +# project_tld: ddev.site +# The top-level domain used for project URLs +# The default "ddev.site" allows DNS lookup via a wildcard +# If you prefer you can change this to "ddev.local" to preserve +# pre-v1.9 behavior. + +# ngrok_args: --basic-auth username:pass1234 +# Provide extra flags to the "ngrok http" command, see +# https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h" + +# disable_settings_management: false +# If true, DDEV will not create CMS-specific settings files like +# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php +# In this case the user must provide all such settings. + +# You can inject environment variables into the web container with: +# web_environment: +# - SOMEENV=somevalue +# - SOMEOTHERENV=someothervalue + +# no_project_mount: false +# (Experimental) If true, DDEV will not mount the project into the web container; +# the user is responsible for mounting it manually or via a script. +# This is to enable experimentation with alternate file mounting strategies. +# For advanced users only! + +# bind_all_interfaces: false +# If true, host ports will be bound on all network interfaces, +# not the localhost interface only. This means that ports +# will be available on the local network if the host firewall +# allows it. + +# default_container_timeout: 120 +# The default time that DDEV waits for all containers to become ready can be increased from +# the default 120. This helps in importing huge databases, for example. + +#web_extra_exposed_ports: +#- name: nodejs +# container_port: 3000 +# http_port: 2999 +# https_port: 3000 +#- name: something +# container_port: 4000 +# https_port: 4000 +# http_port: 3999 +# Allows a set of extra ports to be exposed via ddev-router +# Fill in all three fields even if you don’t intend to use the https_port! +# If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start. +# +# The port behavior on the ddev-webserver must be arranged separately, for example +# using web_extra_daemons. +# For example, with a web app on port 3000 inside the container, this config would +# expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998 +# web_extra_exposed_ports: +# - name: myapp +# container_port: 3000 +# http_port: 9998 +# https_port: 9999 + +#web_extra_daemons: +#- name: "http-1" +# command: "/var/www/html/node_modules/.bin/http-server -p 3000" +# directory: /var/www/html +#- name: "http-2" +# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000" +# directory: /var/www/html + +# override_config: false +# By default, config.*.yaml files are *merged* into the configuration +# But this means that some things can't be overridden +# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge +# and you can't erase existing hooks or all environment variables. +# However, with "override_config: true" in a particular config.*.yaml file, +# 'use_dns_when_possible: false' can override the existing values, and +# hooks: +# post-start: [] +# or +# web_environment: [] +# or +# additional_hostnames: [] +# can have their intended affect. 'override_config' affects only behavior of the +# config.*.yaml file it exists in. + +# Many DDEV commands can be extended to run tasks before or after the +# DDEV command is executed, for example "post-start", "post-import-db", +# "pre-composer", "post-composer" +# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more +# information on the commands that can be extended and the tasks you can define +# for them. Example: +#hooks: +# post-start: +# - exec: composer install -d /var/www/html diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2de7205 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,25 @@ +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# Markdown-Files +[*.md] +max_line_length = 80 + +# YAML,Files +[*.{yaml,yml}] +indent_size = 2 + +# XLF-Files +[*.xlf] +indent_style = tab + +# SQL-Files +[*.sql] +indent_style = tab +indent_size = 2 diff --git a/.gitignore b/.gitignore index c89f094..0089304 100644 --- a/.gitignore +++ b/.gitignore @@ -1,73 +1,6 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -### macOS template -*.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk +/.Build/ +/.ddev/* +!/.ddev/config.yaml +/.php-cs-fixer.cache +/.idea +/composer.lock diff --git a/Build/php-cs-fixer.php b/Build/php-cs-fixer.php new file mode 100644 index 0000000..9874c4d --- /dev/null +++ b/Build/php-cs-fixer.php @@ -0,0 +1,9 @@ +getFinder() + ->in(__DIR__ . '/..') +; +return $config; diff --git a/Build/rector.php b/Build/rector.php new file mode 100644 index 0000000..ddcbc04 --- /dev/null +++ b/Build/rector.php @@ -0,0 +1,37 @@ +sets([ + LevelSetList::UP_TO_PHP_81, + Typo3LevelSetList::UP_TO_TYPO3_11, + ]); + + // Define your target version which you want to support + $rectorConfig->phpVersion(PhpVersion::PHP_81); + + // If you only want to process one/some TYPO3 extension(s), you can specify its path(s) here. + // If you use the option --config change __DIR__ to getcwd() + $rectorConfig->paths([ + __DIR__ . '/..', + ]); + + // When you use rector, there are rules that require some more actions like creating UpgradeWizards for outdated TCA types. + // To fully support you, we added some warnings. So watch out for them. + + // If you use importNames(), you should consider excluding some TYPO3 files. + $rectorConfig->skip([ + __DIR__ . '/../.Build/*', + __DIR__ . '/../.ddev/*', + __DIR__ . '/../Build/*', + __DIR__ . '/../Configuration/TypoScript/*', // exclude typescript which would result in false positive processing + ]); +}; diff --git a/Classes/Controller/NewsBackendAjaxController.php b/Classes/Controller/NewsBackendAjaxController.php index 4f8249e..210f119 100644 --- a/Classes/Controller/NewsBackendAjaxController.php +++ b/Classes/Controller/NewsBackendAjaxController.php @@ -1,4 +1,5 @@ conf['action']) { - case 'loadList': - $content .= $this->loadList(); - break; - case 'expandTree': - $content .= $this->expandTree(); - break; - default: - $content .= 'no action given'; - } + match ($this->conf['action']) { + 'loadList' => $content .= $this->loadList(), + 'expandTree' => $content .= $this->expandTree(), + default => $content .= 'no action given', + }; $response->getBody()->write($content); return $response; @@ -106,5 +97,4 @@ private function expandTree() $content = $module->ajaxExpandCollapse($this->conf); return $content; } - } diff --git a/Classes/Database/Database.php b/Classes/Database/Database.php index 1016e26..9f0c78b 100644 --- a/Classes/Database/Database.php +++ b/Classes/Database/Database.php @@ -20,8 +20,6 @@ /** * Class Database - * - * @package RG\TtNews */ class Database implements SingletonInterface { @@ -30,7 +28,6 @@ class Database implements SingletonInterface */ protected $connectionPool; - /** * @param $tableName * @@ -58,9 +55,14 @@ public function admin_get_fields($tableName) */ public function exec_SELECT_queryArray($queryParts) { - return $this->exec_SELECTquery($queryParts['SELECT'], $queryParts['FROM'], $queryParts['WHERE'], - $queryParts['GROUPBY'], $queryParts['ORDERBY'], $queryParts['LIMIT']); - + return $this->exec_SELECTquery( + $queryParts['SELECT'], + $queryParts['FROM'], + $queryParts['WHERE'], + $queryParts['GROUPBY'], + $queryParts['ORDERBY'], + $queryParts['LIMIT'] + ); } /** @@ -101,7 +103,6 @@ public function exec_SELECTquery( */ public function SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '') { - // Table and fieldnames should be "SQL-injection-safe" when supplied to this function // Build basic query $query = 'SELECT ' . $select_fields . ' FROM ' . $from_table . ((string)$where_clause !== '' ? ' WHERE ' . $where_clause : ''); @@ -157,8 +158,10 @@ public function exec_SELECTgetRows( if ($firstRecord) { $firstRecord = false; if (!array_key_exists($uidIndexField, $record)) { - throw new InvalidArgumentException('The given $uidIndexField "' . $uidIndexField . '" is not available in the result.', - 1432933855); + throw new InvalidArgumentException( + 'The given $uidIndexField "' . $uidIndexField . '" is not available in the result.', + 1_432_933_855 + ); } } $output[$record[$uidIndexField]] = $record; @@ -197,7 +200,6 @@ public function fullQuoteStr($str, $table, $allowNull = false) public function cleanIntList($list) { return implode(',', GeneralUtility::intExplode(',', $list)); - } /** @@ -289,7 +291,7 @@ protected function getSelectMmQueryParts( 'WHERE' => $mmWhere . ' ' . $whereClause, 'GROUPBY' => $groupBy, 'ORDERBY' => $orderBy, - 'LIMIT' => $limit + 'LIMIT' => $limit, ]; } @@ -324,7 +326,7 @@ public function exec_SELECTcountRows($field, $table, $where = '1=1') $count = false; $resultSet = $this->exec_SELECTquery('COUNT(' . $field . ')', $table, $where); if ($resultSet !== false) { - list($count) = $this->sql_fetch_row($resultSet); + [$count] = $this->sql_fetch_row($resultSet); $count = (int)$count; } @@ -354,15 +356,21 @@ public function exec_SELECT_mm_query( $orderBy = '', $limit = '' ) { - $queryParts = $this->getSelectMmQueryParts($select, $local_table, $mm_table, $foreign_table, $whereClause, - $groupBy, $orderBy, $limit); + $queryParts = $this->getSelectMmQueryParts( + $select, + $local_table, + $mm_table, + $foreign_table, + $whereClause, + $groupBy, + $orderBy, + $limit + ); return $this->exec_SELECT_queryArray($queryParts); } /** - * @param string $table - * * @return Connection */ protected function getConnection(string $table) @@ -379,6 +387,6 @@ protected function getConnection(string $table) */ public static function getInstance() { - return GeneralUtility::makeInstance(__CLASS__); + return GeneralUtility::makeInstance(self::class); } } diff --git a/Classes/EventListener/HandleAfterFormEnginePageInitialized.php b/Classes/EventListener/HandleAfterFormEnginePageInitialized.php index 612c473..60917ca 100644 --- a/Classes/EventListener/HandleAfterFormEnginePageInitialized.php +++ b/Classes/EventListener/HandleAfterFormEnginePageInitialized.php @@ -2,13 +2,14 @@ namespace RG\TtNews\EventListener; - +use Doctrine\DBAL\DBALException; use RG\TtNews\Database\Database; use RG\TtNews\Utility\Div; use TYPO3\CMS\Backend\Controller\Event\AfterFormEnginePageInitializedEvent; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -16,9 +17,7 @@ class HandleAfterFormEnginePageInitialized { /** - * @param AfterFormEnginePageInitializedEvent $event - * - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function __invoke(AfterFormEnginePageInitializedEvent $event): void { @@ -47,7 +46,7 @@ public function __invoke(AfterFormEnginePageInitializedEvent $event): void $notAllowedItems = []; - $allowedItems = $this->getBeUser()->getTSConfig()['tt_newsPerms.']['tt_news_cat.']['allowedItems']; + $allowedItems = $this->getBeUser()->getTSConfig()['tt_newsPerms.']['tt_news_cat.']['allowedItems'] ?? ''; $allowedItems = $allowedItems ? GeneralUtility::intExplode( ',', $allowedItems @@ -70,7 +69,7 @@ public function __invoke(AfterFormEnginePageInitializedEvent $event): void FlashMessage::class, $notAllowedItemsMessage, '', - FlashMessage::WARNING + AbstractMessage::WARNING ); $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); @@ -83,7 +82,6 @@ public function __invoke(AfterFormEnginePageInitializedEvent $event): void } } - /** * @return BackendUserAuthentication */ diff --git a/Classes/Form/FormDataProvider.php b/Classes/Form/FormDataProvider.php index b9c1dec..3c0a9aa 100644 --- a/Classes/Form/FormDataProvider.php +++ b/Classes/Form/FormDataProvider.php @@ -14,9 +14,9 @@ * * The TYPO3 project - inspiring people to share! */ - use TYPO3\CMS\Backend\Form\FormDataProviderInterface; - +use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Fill the news records with default values @@ -24,7 +24,6 @@ */ class FormDataProvider implements FormDataProviderInterface { - /** * @param array $result * @@ -36,9 +35,8 @@ public function addData(array $result) return $result; } - $result['databaseRow']['datetime'] = $GLOBALS['EXEC_TIME']; + $result['databaseRow']['datetime'] = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'); return $result; } - -} \ No newline at end of file +} diff --git a/Classes/Helper/Helpers.php b/Classes/Helper/Helpers.php index aa78204..31879e2 100644 --- a/Classes/Helper/Helpers.php +++ b/Classes/Helper/Helpers.php @@ -27,7 +27,7 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - +use Doctrine\DBAL\DBALException; use RG\TtNews\Database\Database; use RG\TtNews\Plugin\TtNews; use TYPO3\CMS\Core\TimeTracker\TimeTracker; @@ -39,24 +39,19 @@ * * * @author Rupert Germann - * @package TYPO3 - * @subpackage tt_news */ class Helpers { - /** * @var TtNews */ - var $pObj; - + public $pObj; public function __construct(&$pObj) { $this->pObj = &$pObj; } - /** * checks for each field of a list of items if it exists in the tt_news table and returns the validated fields * @@ -68,7 +63,7 @@ public function __construct(&$pObj) */ public function validateFields($fieldlist, $existingFields) { - $checkedFields = array(); + $checkedFields = []; $fArr = GeneralUtility::trimExplode(',', $fieldlist, 1); foreach ($fArr as $fN) { if (in_array($fN, $existingFields)) { @@ -80,7 +75,6 @@ public function validateFields($fieldlist, $existingFields) return $checkedFieldlist; } - /** * Checks the visibility of a list of category-records * @@ -94,15 +88,18 @@ public function checkRecords($recordlist) if ($recordlist) { $tempRecs = GeneralUtility::trimExplode(',', $recordlist, 1); // debug($temp); - $newtemp = array(); + $newtemp = []; foreach ($tempRecs as $val) { if ($val === '0') { $this->pObj->nocat = true; } - $val = intval($val); + $val = (int)$val; if ($val) { - $test = $GLOBALS['TSFE']->sys_page->checkRecord('tt_news_cat', $val, - 1); // test, if the record is visible + $test = $GLOBALS['TSFE']->sys_page->checkRecord( + 'tt_news_cat', + $val, + 1 + ); // test, if the record is visible if ($test) { $newtemp[] = $val; } @@ -119,7 +116,6 @@ public function checkRecords($recordlist) return $clearedlist; } - /** * Searches the category rootline (up) for a single view pid. If nothing is found in the current * category, the single view pid of the parent categories is taken (recusivly). @@ -127,13 +123,16 @@ public function checkRecords($recordlist) * @param int $currentCategory : Uid of the current category * * @return int first found single view pid - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function getRecursiveCategorySinglePid($currentCategory) { $result = null; - $res = Database::getInstance()->exec_SELECTquery('uid,parent_category,single_pid', 'tt_news_cat', - 'tt_news_cat.uid=' . $currentCategory . $this->pObj->SPaddWhere . $this->pObj->enableCatFields); + $res = Database::getInstance()->exec_SELECTquery( + 'uid,parent_category,single_pid', + 'tt_news_cat', + 'tt_news_cat.uid=' . $currentCategory . $this->pObj->SPaddWhere . $this->pObj->enableCatFields + ); $row = Database::getInstance()->sql_fetch_assoc($res); if ($row['single_pid'] > 0) { $result = $row['single_pid']; @@ -144,7 +143,6 @@ public function getRecursiveCategorySinglePid($currentCategory) return $result; } - /** * extends a given list of categories by their subcategories. This function returns a nested array with * subcategories (the function getSubCategories() return only a commaseparated list of category UIDs) @@ -155,11 +153,11 @@ public function getRecursiveCategorySinglePid($currentCategory) * @param int $cc: counter to detect recursion in nested categories * * @return array all categories in a nested array - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function getSubCategoriesForMenu($catlist, $fields, $addWhere, $cc = 0) { - $pcatArr = array(); + $pcatArr = []; $from_table = 'tt_news_cat'; $where_clause = 'tt_news_cat.parent_category IN (' . $catlist . ')' . $this->pObj->SPaddWhere . $this->pObj->enableCatFields; @@ -169,7 +167,9 @@ public function getSubCategoriesForMenu($catlist, $fields, $addWhere, $cc = 0) $fields, $from_table, $where_clause, - '', $orderBy); + '', + $orderBy + ); while (($row = Database::getInstance()->sql_fetch_assoc($res))) { $cc++; @@ -187,7 +187,6 @@ public function getSubCategoriesForMenu($catlist, $fields, $addWhere, $cc = 0) return $pcatArr; } - /** * divides the bodytext field of a news single view to pages and returns the part of the bodytext * that is choosen by piVars[$pointerName] @@ -200,10 +199,13 @@ public function getSubCategoriesForMenu($catlist, $fields, $addWhere, $cc = 0) public function makeMultiPageSView($bodytext, $lConf) { $pointerName = $this->pObj->config['singleViewPointerName']; - $pagenum = $this->pObj->piVars[$pointerName] ? $this->pObj->piVars[$pointerName] : 0; - $textArr = GeneralUtility::trimExplode($this->pObj->config['pageBreakToken'], $bodytext, - 1); - $pagecount = count($textArr); + $pagenum = $this->pObj->piVars[$pointerName] ?: 0; + $textArr = GeneralUtility::trimExplode( + $this->pObj->config['pageBreakToken'], + $bodytext, + 1 + ); + $pagecount = is_countable($textArr) ? count($textArr) : 0; $pagebrowser = ''; // render a pagebrowser for the single view if ($pagecount > 1) { @@ -215,23 +217,20 @@ public function makeMultiPageSView($bodytext, $lConf) $this->pObj->LOCAL_LANG[$this->pObj->LLkey]['pi_list_browseresults_page'] = ' '; } $pbConf = $this->pObj->conf['singleViewPageBrowser.']; - $markerArray = array(); + $markerArray = []; $markerArray = $this->pObj->getPagebrowserContent($markerArray, $pbConf, $pointerName); $pagebrowser = $markerArray['###BROWSE_LINKS###']; } - return array( + return [ $this->pObj->formatStr($this->pObj->local_cObj->stdWrap($textArr[$pagenum], $lConf['content_stdWrap.'])), - $pagebrowser - ); + $pagebrowser, + ]; } - /** * Converts the piVars 'pS' and 'pL' to a human readable format which will be filled to * the piVars 'year' and 'month'. - * - * @return void */ public function convertDates() { @@ -249,35 +248,52 @@ public function convertDates() $this->pObj->piVars['day'] = date('j', (int)($this->pObj->piVars['pS'] ?? 0)); } if (($this->pObj->piVars['year'] ?? false) || ($this->pObj->piVars['month'] ?? false) || ($this->pObj->piVars['day'] ?? false)) { - $mon = intval(($this->pObj->piVars['month'] ?? false) ?: 1); - $day = intval(($this->pObj->piVars['day'] ?? false) ?: 1); + $mon = (int)(($this->pObj->piVars['month'] ?? false) ?: 1); + $day = (int)(($this->pObj->piVars['day'] ?? false) ?: 1); $this->pObj->piVars['pS'] = mktime(0, 0, 0, $mon, $day, (int)($this->pObj->piVars['year'] ?? 0)); switch ($this->pObj->config['archiveMode']) { - case 'month' : - $this->pObj->piVars['pL'] = mktime(0, 0, 0, $mon + 1, 1, - (int)($this->pObj->piVars['year'] ?? 0)) - (int)($this->pObj->piVars['pS'] ?? 0) - 1; + case 'month': + $this->pObj->piVars['pL'] = mktime( + 0, + 0, + 0, + $mon + 1, + 1, + (int)($this->pObj->piVars['year'] ?? 0) + ) - (int)($this->pObj->piVars['pS'] ?? 0) - 1; break; - case 'quarter' : - $this->pObj->piVars['pL'] = mktime(0, 0, 0, $mon + 3, 1, - (int)($this->pObj->piVars['year'] ?? 0)) - (int)($this->pObj->piVars['pS'] ?? 0) - 1; + case 'quarter': + $this->pObj->piVars['pL'] = mktime( + 0, + 0, + 0, + $mon + 3, + 1, + (int)($this->pObj->piVars['year'] ?? 0) + ) - (int)($this->pObj->piVars['pS'] ?? 0) - 1; break; - case 'year' : - $this->pObj->piVars['pL'] = mktime(0, 0, 0, 1, 1, - (int)($this->pObj->piVars['year'] ?? 0) + 1) - (int)($this->pObj->piVars['pS'] ?? 0) - 1; + case 'year': + $this->pObj->piVars['pL'] = mktime( + 0, + 0, + 0, + 1, + 1, + (int)($this->pObj->piVars['year'] ?? 0) + 1 + ) - (int)($this->pObj->piVars['pS'] ?? 0) - 1; unset($this->pObj->piVars['month']); break; } } } - /** * inserts pagebreaks after a certain amount of words * * @param string $text text which can contain manully inserted 'pageBreakTokens' - * @param integer $firstPageWordCrop amount of words in the subheader (short). The length of the first page will + * @param int $firstPageWordCrop amount of words in the subheader (short). The length of the first page will * be reduced by that amount of words added to the value of * $this->conf['cropWordsFromFirstPage']. * @@ -285,17 +301,15 @@ public function convertDates() */ public function insertPagebreaks($text, $firstPageWordCrop) { - - $text = str_replace(array('

'), array('

' . chr(10)), $text); + $text = str_replace(['

'], ['

' . chr(10)], $text); $paragraphToken = chr(10); $paragraphs = explode($paragraphToken, $text); // get paragraphs - $wtmp = array(); - $firstPageCrop = $firstPageWordCrop + intval($this->pObj->conf['cropWordsFromFirstPage']); + $wtmp = []; + $firstPageCrop = $firstPageWordCrop + (int)($this->pObj->conf['cropWordsFromFirstPage']); $cc = 0; // wordcount $isfirst = true; // first paragraph foreach ($paragraphs as $k => $p) { - if (trim($paragraphs[$k + 1]) == ' ') { unset($paragraphs[$k + 1]); } @@ -309,18 +323,21 @@ public function insertPagebreaks($text, $firstPageWordCrop) } $words = explode(' ', $p); // get words - $pArr = array(); + $pArr = []; $break = false; foreach ($words as $w) { $fpc = ($isfirst && !$this->pObj->conf['subheaderOnAllSViewPages'] ? $firstPageCrop : 0); $wc = $this->pObj->config['maxWordsInSingleView'] - $fpc; - if (strpos($w, $this->pObj->config['pageBreakToken'])) { // manually inserted pagebreaks, unset counter + if (strpos($w, (string)$this->pObj->config['pageBreakToken'])) { // manually inserted pagebreaks, unset counter $cc = 0; $pArr[] = $w; $isfirst = false; - } elseif ($cc >= MathUtility::forceIntegerInRange($wc, 0, - $this->pObj->config['maxWordsInSingleView'])) { // more words than maxWordsInSingleView + } elseif ($cc >= MathUtility::forceIntegerInRange( + $wc, + 0, + $this->pObj->config['maxWordsInSingleView'] + )) { // more words than maxWordsInSingleView if (GeneralUtility::inList('.,!,?', substr($w, -1))) { if ($this->pObj->conf['useParagraphAsPagebreak']) { // break at paragraph $break = true; @@ -363,11 +380,12 @@ public function displayErrors() } return '
- plugin.tt_news ERROR:
' . implode('
', - $this->pObj->errors) . '
' . $msg . '
'; + plugin.tt_news ERROR:
' . implode( + '
', + $this->pObj->errors + ) . '
' . $msg . ''; } - /** * cleans the content for rss feeds. removes ' ' and '?;' (dont't know if the scond one matters in real-life). * The rest of the cleaning/character-conversion is done by the stdWrap functions htmlspecialchars,stripHtml and @@ -379,21 +397,17 @@ public function displayErrors() */ public function cleanXML($str) { - $cleanedStr = preg_replace(array('/ /', '/&;/', '//'), array(' ', '&;', '<', '>'), $str); + $cleanedStr = preg_replace(['/ /', '/&;/', '//'], [' ', '&;', '<', '>'], $str); return $cleanedStr; } - - - - /** * Generates the date format needed for Atom feeds * see: http://www.w3.org/TR/NOTE-datetime (same as ISO 8601) * in php5 it would be so easy: date('c', $row['datetime']); * - * @param integer $datetime the datetime value to be converted to w3c format + * @param int $datetime the datetime value to be converted to w3c format * * @return string datetime in w3c format */ @@ -417,4 +431,3 @@ public function getW3cDate($datetime) return strftime('%Y-%m-%dT%H:%M:%S', $datetime) . $offset . ':00'; } } - diff --git a/Classes/Helper/ItemsProcFunc.php b/Classes/Helper/ItemsProcFunc.php index 7948ca9..da78499 100644 --- a/Classes/Helper/ItemsProcFunc.php +++ b/Classes/Helper/ItemsProcFunc.php @@ -42,8 +42,6 @@ * * @author Mathias Bolt Lesniak * @author Rupert Germann - * @package TYPO3 - * @subpackage tt_news */ class ItemsProcFunc { @@ -54,15 +52,15 @@ class ItemsProcFunc * * @return array $config array with extra codes merged in */ - function user_insertExtraCodes($config) + public function user_insertExtraCodes($config) { if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['what_to_display'] ?? null)) { - $config['items'] = array_merge($config['items'], - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['what_to_display']); + $config['items'] = array_merge( + $config['items'], + $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['what_to_display'] + ); } return $config; } - } - diff --git a/Classes/Hooks/DataHandlerHook.php b/Classes/Hooks/DataHandlerHook.php index f058249..ce803a5 100644 --- a/Classes/Hooks/DataHandlerHook.php +++ b/Classes/Hooks/DataHandlerHook.php @@ -27,7 +27,6 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * Class 'tx_ttnews_tcemain' for the tt_news extension. * @@ -35,7 +34,6 @@ * * @author Rupert Germann */ - use Doctrine\DBAL\DBALException; use RG\TtNews\Database\Database; use RG\TtNews\Utility\Div; @@ -44,18 +42,16 @@ use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Exception; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageQueue; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Utility\GeneralUtility; - /** * Class being included by TCEmain using a hook * * @author Rupert Germann - * @package TYPO3 - * @subpackage tt_news */ class DataHandlerHook { @@ -77,8 +73,6 @@ class DataHandlerHook * @param string $id : The records id (if any) * @param object $pObj : Reference to the parent object (TCEmain) * - * @return void - * @access public * @throws DBALException * @throws Exception */ @@ -86,19 +80,18 @@ public function processDatamap_preProcessFieldArray(&$fieldArray, $table, $id, & { if ($table == 'tt_news_cat' && is_int($id)) { // prevent moving of categories into their rootline - $newParent = intval($fieldArray['parent_category']); + $newParent = (int)($fieldArray['parent_category']); if ($newParent && GeneralUtility::inList( - Div::getSubCategories( - $id, - $this->SPaddWhere . $this->enableCatFields - ), - $newParent - )) { + Div::getSubCategories( + $id, + $this->SPaddWhere . $this->enableCatFields + ), + $newParent + )) { $sourceRec = BackendUtility::getRecord($table, $id, 'title'); $targetRec = BackendUtility::getRecord($table, $fieldArray['parent_category'], 'title'); - $messageString = "Attempt to move category '" . $sourceRec['title'] . "' ($id) to inside of its own rootline (at category '" . $targetRec['title'] . "' ($newParent))."; $pObj->log($table, $id, 2, 0, 1, "processDatamap: $messageString", 1); @@ -107,14 +100,14 @@ public function processDatamap_preProcessFieldArray(&$fieldArray, $table, $id, & FlashMessage::class, $messageString, 'ERROR', // the header is optional - FlashMessage::ERROR, + AbstractMessage::ERROR, // the severity is optional as well and defaults to \TYPO3\CMS\Core\Messaging\FlashMessage::OK true // optional, whether the message should be stored in the session or only in the \TYPO3\CMS\Core\Messaging\FlashMessageQueue object (default is FALSE) ); $this->enqueueFlashMessage($message); // unset fieldArray to prevent saving of the record - $fieldArray = array(); + $fieldArray = []; return; } @@ -122,7 +115,7 @@ public function processDatamap_preProcessFieldArray(&$fieldArray, $table, $id, & if ($table == 'tt_news') { // copy "type" field in localized records - if (!is_int($id) && $fieldArray['l18n_parent']) { // record is a new localization + if (!is_int($id) && ($fieldArray['l18n_parent'] ?? false)) { // record is a new localization $rec = BackendUtility::getRecord( $table, $fieldArray['l18n_parent'], @@ -137,7 +130,7 @@ public function processDatamap_preProcessFieldArray(&$fieldArray, $table, $id, & } $categories = []; - $recID = (($fieldArray['l18n_parent'] > 0) ? $fieldArray['l18n_parent'] : $id); + $recID = ((($fieldArray['l18n_parent'] ?? 0) > 0) ? $fieldArray['l18n_parent'] : $id); // get categories from the tt_news record in db $cRes = Database::getInstance()->exec_SELECT_mm_query( 'tt_news_cat.uid, tt_news_cat.title', @@ -155,10 +148,10 @@ public function processDatamap_preProcessFieldArray(&$fieldArray, $table, $id, & $notAllowedItems = []; - $allowedItems = $this->getBeUser()->getTSConfig()['tt_newsPerms.']['tt_news_cat.']['allowedItems']; + $allowedItems = $this->getBeUser()->getTSConfig()['tt_newsPerms.']['tt_news_cat.']['allowedItems'] ?? ''; $allowedItems = $allowedItems ? GeneralUtility::intExplode(',', $allowedItems) : Div::getAllowedTreeIDs(); - $wantedCategories = $fieldArray['category'] ? GeneralUtility::intExplode(',', $fieldArray['category']) : []; + $wantedCategories = GeneralUtility::intExplode(',', $fieldArray['category'] ?? ''); foreach ($wantedCategories as $wantedCategory) { $categories[$wantedCategory] = $wantedCategory; } @@ -174,18 +167,17 @@ public function processDatamap_preProcessFieldArray(&$fieldArray, $table, $id, & ->sL( 'LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xml:tt_news.notAllowedCategoryError' ) . implode( - ', ', - $notAllowedItems - ); + ', ', + $notAllowedItems + ); $pObj->log($table, $id, 2, 0, 1, 'processDatamap: ' . $messageString, 1); // unset fieldArray to prevent saving of the record - $fieldArray = array(); + $fieldArray = []; } } } - /** * @param $message * @@ -231,7 +223,6 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, $fi } } - /** * This method is called by a hook in the TYPO3 Core Engine (TCEmain) when a command was executed * (copy,move,delete...). For tt_news it is used to disable saving of the current record if it has an editlock or @@ -243,8 +234,6 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, $fi * @param array $value : The new value of the field which has been changed * @param object $pObj : Reference to the parent object (TCEmain) * - * @return void - * @access public * @throws DBALException * @throws Exception */ @@ -259,9 +248,9 @@ public function processCmdmap_preProcess($command, &$table, &$id, $value, &$pObj 2, 0, 1, - "processCmdmap [editlock]: Attempt to " . $command . " a record from table '%s' which is locked by an 'editlock' (= record can only be edited by admins).", + 'processCmdmap [editlock]: Attempt to ' . $command . " a record from table '%s' which is locked by an 'editlock' (= record can only be edited by admins).", 1, - array($table) + [$table] ); // unset table to prevent saving $table = ''; @@ -290,7 +279,7 @@ public function processCmdmap_preProcess($command, &$table, &$id, $value, &$pObj $notAllowedItems = []; - $allowedItems = $this->getBeUser()->getTSConfig()['tt_newsPerms.']['tt_news_cat.']['allowedItems']; + $allowedItems = $this->getBeUser()->getTSConfig()['tt_newsPerms.']['tt_news_cat.']['allowedItems'] ?? ''; $allowedItems = $allowedItems ? GeneralUtility::intExplode(',', $allowedItems) : Div::getAllowedTreeIDs(); foreach ($categories as $categoryId => $categoryTitle) { @@ -304,9 +293,9 @@ public function processCmdmap_preProcess($command, &$table, &$id, $value, &$pObj ->sL( 'LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xml:tt_news.notAllowedCategoryError' ) . implode( - ', ', - $notAllowedItems - ); + ', ', + $notAllowedItems + ); $pObj->log($table, $id, 2, 0, 1, 'processCmdmap: ' . $messageString, 1); $table = ''; // unset table to prevent saving @@ -328,14 +317,14 @@ public function processCmdmap_postProcess($command, $table, $srcId, $destId, &$p // copy records recursively from Drag&Drop in the category manager if ($table == 'tt_news_cat' && $command == 'DDcopy') { $srcRec = BackendUtility::getRecordWSOL('tt_news_cat', $srcId); - $overrideValues = array('parent_category' => $destId, 'hidden' => 1); + $overrideValues = ['parent_category' => $destId, 'hidden' => 1]; $newRecID = $pObj->copyRecord($table, $srcId, $srcRec['pid'], 1, $overrideValues); - $CPtable = $this->int_recordTreeInfo(array(), $srcId, 99, $newRecID, $table, $pObj); + $CPtable = $this->int_recordTreeInfo([], $srcId, 99, $newRecID, $table, $pObj); foreach ($CPtable as $recUid => $recParent) { $newParent = $pObj->copyMappingArray[$table][$recParent]; if (isset($newParent)) { - $overrideValues = array('parent_category' => $newParent, 'hidden' => 1); + $overrideValues = ['parent_category' => $newParent, 'hidden' => 1]; $pObj->copyRecord($table, $recUid, $srcRec['pid'], 1, $overrideValues); } else { $pObj->log($table, $srcId, 5, 0, 1, 'Something went wrong during copying branch'); @@ -346,7 +335,7 @@ public function processCmdmap_postProcess($command, $table, $srcId, $destId, &$p // delete records recursively from Context Menu in the category manager if ($table == 'tt_news_cat' && $command == 'DDdelete') { $pObj->deleteRecord($table, $srcId, false); - $CPtable = $this->int_recordTreeInfo(array(), $srcId, 99, $srcId, $table, $pObj); + $CPtable = $this->int_recordTreeInfo([], $srcId, 99, $srcId, $table, $pObj); foreach ($CPtable as $recUid => $p) { if (isset($recUid)) { @@ -380,7 +369,7 @@ protected function int_recordTreeInfo($CPtable, $srcId, $counter, $rootID, $tabl $mres = Database::getInstance()->exec_SELECTquery( 'uid', $table, - 'parent_category=' . intval($srcId) . $pObj->deleteClause($table) . $addW, + 'parent_category=' . (int)$srcId . $pObj->deleteClause($table) . $addW, '', '' ); @@ -396,7 +385,6 @@ protected function int_recordTreeInfo($CPtable, $srcId, $counter, $rootID, $tabl } } - return $CPtable; } @@ -418,7 +406,3 @@ protected function getLanguageService() return $GLOBALS['LANG']; } } - - - - diff --git a/Classes/Hooks/PageModuleHook.php b/Classes/Hooks/PageModuleHook.php index c1e02dd..040708a 100644 --- a/Classes/Hooks/PageModuleHook.php +++ b/Classes/Hooks/PageModuleHook.php @@ -25,16 +25,12 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - use TYPO3\CMS\Core\Utility\GeneralUtility; - /** * Hook to display verbose information about pi1 plugin in Web>Page module * * @author Dmitry Dulepov - * @package TYPO3 - * @subpackage tx_tt_news */ class PageModuleHook { @@ -52,8 +48,10 @@ public function getExtensionSummary($params, &$pObj) if ($params['row']['list_type'] == 9) { $data = GeneralUtility::xml2array($params['row']['pi_flexform']); if (is_array($data) && $data['data']['sDEF']['lDEF']['what_to_display']['vDEF']) { - $result = 'tt_news: ' . sprintf($GLOBALS['LANG']->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:cms_layout.mode'), - $data['data']['sDEF']['lDEF']['what_to_display']['vDEF']); + $result = 'tt_news: ' . sprintf( + $GLOBALS['LANG']->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:cms_layout.mode'), + $data['data']['sDEF']['lDEF']['what_to_display']['vDEF'] + ); } if (!$result) { $result = 'tt_news: ' . $GLOBALS['LANG']->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:cms_layout.not_configured'); @@ -63,5 +61,3 @@ public function getExtensionSummary($params, &$pObj) return $result; } } - - diff --git a/Classes/Menu/Catmenu.php b/Classes/Menu/Catmenu.php index b454a8e..56e1754 100644 --- a/Classes/Menu/Catmenu.php +++ b/Classes/Menu/Catmenu.php @@ -27,7 +27,7 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - +use Doctrine\DBAL\DBALException; use RG\TtNews\Database\Database; use RG\TtNews\Helper\Helpers; use RG\TtNews\Plugin\TtNews; @@ -37,7 +37,6 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; /** - * * renders the tt_news CATMENU content element * * @author Rupert Germann @@ -64,7 +63,7 @@ class Catmenu /** * @param TtNews $pObj * - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function init(&$pObj) { @@ -75,19 +74,21 @@ public function init(&$pObj) $this->treeObj->tt_news_obj = &$pObj; $this->treeObj->category = $pObj->piVars_catSelection; $this->treeObj->table = 'tt_news_cat'; - $this->treeObj->init($pObj->SPaddWhere . $pObj->enableCatFields . $pObj->catlistWhere, - $pObj->config['catOrderBy']); - $this->treeObj->backPath = TYPO3_mainDir; + $this->treeObj->init( + $pObj->SPaddWhere . $pObj->enableCatFields . $pObj->catlistWhere, + $pObj->config['catOrderBy'] + ); + $this->treeObj->backPath = \TYPO3_MAINDIR; $this->treeObj->parentField = 'parent_category'; $this->treeObj->thisScript = 'index.php?ttnewsID=tt_news_catmenu'; - $this->treeObj->cObjUid = intval($pObj->cObj->data['uid']); - $this->treeObj->fieldArray = array( + $this->treeObj->cObjUid = (int)($pObj->cObj->data['uid']); + $this->treeObj->fieldArray = [ 'uid', 'title', 'title_lang_ol', 'description', - 'image' - ); // those fields will be filled to the array $this->treeObj->tree + 'image', + ]; // those fields will be filled to the array $this->treeObj->tree $this->treeObj->ext_IconMode = '1'; // no context menu on icons $expandable = $lConf['expandable']; @@ -111,12 +112,14 @@ public function init(&$pObj) // get all selected category records from the current storagePid which are not 'root' categories // and add them as tree mounts. Subcategories of selected categories will be excluded. - $cMounts = array(); + $cMounts = []; $nonRootMounts = false; foreach ($selcatArr as $catID) { - - $subres = $this->db->exec_SELECTquery('*', 'tt_news_cat', - 'uid = ' . (int)$catID . $pObj->SPaddWhere . $pObj->enableCatFields . $pObj->catlistWhere); + $subres = $this->db->exec_SELECTquery( + '*', + 'tt_news_cat', + 'uid = ' . (int)$catID . $pObj->SPaddWhere . $pObj->enableCatFields . $pObj->catlistWhere + ); $tmpR = []; while (($subrow = $this->db->sql_fetch_assoc($subres))) { $tmpR[] = $subrow; @@ -131,16 +134,14 @@ public function init(&$pObj) } if ($nonRootMounts) { $this->treeObj->MOUNTS = $cMounts; - } } /** - * * @param array $params * * @return string - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function ajaxExpandCollapse($params) { @@ -156,7 +157,7 @@ public function ajaxExpandCollapse($params) * @param array $params * * @return array - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ protected function initAjaxEnv($params) { diff --git a/Classes/Menu/ClickMenu.php b/Classes/Menu/ClickMenu.php index f93ee04..7e0e921 100755 --- a/Classes/Menu/ClickMenu.php +++ b/Classes/Menu/ClickMenu.php @@ -4,13 +4,12 @@ * Additional items for the clickmenu * * @author Rupert Germann - * @package TYPO3 - * @subpackage tt_news * @link http://www.gnu.org/copyleft/gpl.html */ namespace RG\TtNews\Menu; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\Icon; @@ -44,7 +43,7 @@ class ClickMenu /** * @var array */ - protected $LL = array(); + protected $LL = []; /** * Construct @@ -77,7 +76,7 @@ public function main(&$backRef, $menuItems, $table, $uid) $lCP = $this->backendUser->calcPerms(BackendUtility::getRecord('pages', $rec['pid'])); $doEdit = $lCP & Permission::CONTENT_EDIT; - $menuItems = array(); + $menuItems = []; if ($doEdit) { $menuItems['edit'] = $this->DB_edit($table, $uid); $menuItems['new'] = $this->DB_new($table, $rec); @@ -88,12 +87,12 @@ public function main(&$backRef, $menuItems, $table, $uid) if ($doEdit) { $menuItems['hide'] = $this->DB_hideUnhide($table, $rec, 'hidden'); - $elInfo = array( + $elInfo = [ GeneralUtility::fixed_lgd_cs( BackendUtility::getRecordTitle('tt_news_cat', $rec), $this->backendUser->uc['titleLen'] - ) - ); + ), + ]; $menuItems['spacer2'] = 'spacer'; $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo); } @@ -111,9 +110,9 @@ public function main(&$backRef, $menuItems, $table, $uid) protected function DB_edit($table, $uid) { $loc = 'top.content.list_frame'; - $link = BackendUtility::getModuleUrl('record_edit', array( - 'edit[' . $table . '][' . $uid . ']' => 'edit' - )); + $link = GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit', [ + 'edit[' . $table . '][' . $uid . ']' => 'edit', + ]); $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=' . GeneralUtility::quoteJSvalue($link . '&returnUrl=') . '+top.rawurlencode(' . $this->backRef->frameLocation(($loc . '.document')) . '.pathname+' . $this->backRef->frameLocation(($loc . '.document')) . '.search);}'; return $this->backRef->linkItem( $this->backRef->label('edit'), @@ -137,23 +136,23 @@ protected function DB_new($table, $rec, $newsub = false) $parent = $rec['parent_category']; } - $urlParameters = array( - 'edit' => array( - $table => array( - $rec['pid'] => 'new' - ) - ), - ); + $urlParameters = [ + 'edit' => [ + $table => [ + $rec['pid'] => 'new', + ], + ], + ]; if ($parent) { - $urlParameters['defVals'] = array( - $table => array( - 'parent_category' => $parent - ) - ); + $urlParameters['defVals'] = [ + $table => [ + 'parent_category' => $parent, + ], + ]; } $loc = 'top.content.list_frame'; - $link = BackendUtility::getModuleUrl('record_edit', $urlParameters); + $link = GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit', $urlParameters); $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=' . GeneralUtility::quoteJSvalue($link . '&returnUrl=') . '+top.rawurlencode(' . $this->backRef->frameLocation(($loc . '.document')) . '.pathname+' . $this->backRef->frameLocation(($loc . '.document')) . '.search);}'; $lkey = 'new'; @@ -168,7 +167,6 @@ protected function DB_new($table, $rec, $newsub = false) ); } - /** * Adding CM element for hide/unhide of the input record * @@ -181,8 +179,12 @@ protected function DB_new($table, $rec, $newsub = false) */ protected function DB_hideUnhide($table, $rec, $hideField) { - return $this->DB_changeFlag($table, $rec, $hideField, - $this->backRef->label(($rec[$hideField] ? 'un' : '') . 'hide')); + return $this->DB_changeFlag( + $table, + $rec, + $hideField, + $this->backRef->label(($rec[$hideField] ? 'un' : '') . 'hide') + ); } /** @@ -197,10 +199,10 @@ protected function DB_hideUnhide($table, $rec, $hideField) */ protected function DB_changeFlag($table, $rec, $flagField, $title) { - $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid']; + $uid = $rec['_ORIG_uid'] ?: $rec['uid']; $loc = 'top.content.list_frame'; $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=' . - GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&redirect=') . '+top.rawurlencode(' . + GeneralUtility::quoteJSvalue(GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('tce_db') . '&redirect=') . '+top.rawurlencode(' . $this->backRef->frameLocation($loc . '.document') . '.pathname+' . $this->backRef->frameLocation(($loc . '.document')) . '.search)+' . GeneralUtility::quoteJSvalue( '&data[' . $table . '][' . $uid . '][' . $flagField . ']=' . ($rec[$flagField] ? 0 : 1) . '&prErr=1&vC=' . $this->backendUser->veriCode() @@ -229,7 +231,7 @@ public function DB_delete($table, $uid, $elInfo) { $loc = 'top.content.list_frame'; $jsCode = $loc . '.location.href=' - . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&redirect=') + . GeneralUtility::quoteJSvalue(GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('tce_db') . '&redirect=') . '+top.rawurlencode(' . $this->backRef->frameLocation($loc . '.document') . '.pathname+' . $this->backRef->frameLocation($loc . '.document') . '.search)+' . GeneralUtility::quoteJSvalue( diff --git a/Classes/Middleware/AjaxResolver.php b/Classes/Middleware/AjaxResolver.php index 4b736bd..d916963 100644 --- a/Classes/Middleware/AjaxResolver.php +++ b/Classes/Middleware/AjaxResolver.php @@ -8,8 +8,7 @@ namespace RG\TtNews\Middleware; - - +use Doctrine\DBAL\DBALException; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -38,7 +37,7 @@ class AjaxResolver implements MiddlewareInterface * @param RequestHandlerInterface $handler * * @return ResponseInterface - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { @@ -69,14 +68,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface } $content = ''; - switch ($this->conf['action']) { - case 'expandTree': - $content .= $this->expandTree(); - break; - - default: - throw new \UnexpectedValueException('method not allowd', 1565010424); - } + match ($this->conf['action']) { + 'expandTree' => $content .= $this->expandTree(), + default => throw new \UnexpectedValueException('method not allowd', 1_565_010_424), + }; $response->getBody()->write((string)$content); @@ -85,7 +80,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface /** * @return string - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ private function expandTree() { @@ -93,5 +88,4 @@ private function expandTree() return $module->ajaxExpandCollapse($this->conf); } - } diff --git a/Classes/Module/BaseScriptClass.php b/Classes/Module/BaseScriptClass.php index 0409ba6..d9f4e34 100644 --- a/Classes/Module/BaseScriptClass.php +++ b/Classes/Module/BaseScriptClass.php @@ -1,4 +1,5 @@ main(); - * */ class BaseScriptClass { @@ -108,7 +109,7 @@ class BaseScriptClass * @var array */ public $MOD_MENU = [ - 'function' => [] + 'function' => [], ]; /** @@ -342,11 +343,11 @@ public function extObjContent() FlashMessage::class, $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:no_modules_registered'), $this->getLanguageService()->getLL('title'), - FlashMessage::ERROR + AbstractMessage::ERROR ); - /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */ + /** @var FlashMessageService $flashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); - /** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue $defaultFlashMessageQueue */ + /** @var FlashMessageQueue $defaultFlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } else { diff --git a/Classes/Module/CategoryManager.php b/Classes/Module/CategoryManager.php index 9220bc9..780be36 100644 --- a/Classes/Module/CategoryManager.php +++ b/Classes/Module/CategoryManager.php @@ -8,17 +8,15 @@ namespace RG\TtNews\Module; - use RG\TtNews\Tree\Categorytree; use RG\TtNews\Utility\IconFactory; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Class CategoryManager - * - * @package RG\TtNews\Module */ class CategoryManager extends Categorytree { @@ -55,7 +53,6 @@ class CategoryManager extends Categorytree */ public $backPath; - /** * @param string $icon * @param array $row @@ -68,8 +65,11 @@ public function wrapIcon($icon, $row) if ($row['uid'] > 0 && !isset($row['doktype'])) { // no clickmenu for pages - $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'tt_news_cat_CM', - $row['uid'], 0, '&bank=' . $this->bank); + $theIcon = BackendUtility::wrapClickMenuOnIcon( + $theIcon, + 'tt_news_cat_CM', + $row['uid'] + ); $theIcon = '' . $theIcon . ''; } else { $theIcon = '' . $theIcon . ''; @@ -91,7 +91,7 @@ public function wrapTitle($title, $v, $bank = 0) { if ($v['uid'] > 0) { $hrefTitle = htmlentities('[id=' . $v['uid'] . '] ' . $v['description']); - $out = '' . $title . ''; + $out = '' . $title . ''; // Wrap title in a drag/drop span. $out = '' . $out . ''; @@ -104,11 +104,12 @@ public function wrapTitle($title, $v, $bank = 0) $grsp = ' GRSP'; } if ($this->useStoragePid) { - $pidLbl = sprintf($this->getLanguageService()->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xml:tt_news.treeSelect.pageTitleSuffix'), - $this->storagePid . $grsp); + $pidLbl = sprintf( + $this->getLanguageService()->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xml:tt_news.treeSelect.pageTitleSuffix'), + $this->storagePid . $grsp + ); } else { $pidLbl = $this->getLanguageService()->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xml:tt_news.treeSelect.pageTitleSuffixNoGrsp'); - } $pidLbl = ' ' . $pidLbl . ''; $hrefTitle = $this->getLanguageService()->sL('LLL:EXT:tt_news/Classes/Module/locallang.xml:showAllResetSel'); @@ -121,7 +122,6 @@ public function wrapTitle($title, $v, $bank = 0) return $out; } - /** * Creates the control panel for a single record in the listing. * @@ -135,22 +135,25 @@ public function makeControl($table, $row) global $TCA; // Initialize: - $cells = array(); + $cells = []; // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id) if ($this->mayUserEditCategories) { $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; - $cells[] = '' . - '' . + $cells[] = '' . + '' . ''; } // "Hide/Unhide" links: $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled']; if ($this->mayUserEditCategories && $hiddenField && $TCA[$table]['columns'][$hiddenField] && - (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', - $table . ':' . $hiddenField)) + (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $this->getBackendUser()->check( + 'non_exclude_fields', + $table . ':' . $hiddenField + )) ) { /** * @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory @@ -158,15 +161,19 @@ public function makeControl($table, $row) $iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class); if ($row[$hiddenField]) { $params = '&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=0'; - $cells[] = '' . - $iconFactory->getIcon('actions-edit-unhide',Icon::SIZE_SMALL)->render() . + $cells[] = '' . + $iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . ''; } else { $params = '&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=1'; - $cells[] = '' . - $iconFactory->getIcon('actions-edit-hide',Icon::SIZE_SMALL)->render() . + $cells[] = '' . + $iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . ''; } } @@ -195,6 +202,4 @@ public function issueCommand($params, $rUrl = ''): string return $url; } - - } diff --git a/Classes/Module/LegacyBackendUtility.php b/Classes/Module/LegacyBackendUtility.php index e6f2931..4501e7a 100644 --- a/Classes/Module/LegacyBackendUtility.php +++ b/Classes/Module/LegacyBackendUtility.php @@ -1,9 +1,8 @@ buildUriFromRoute($moduleName, $urlParameters); - } catch (\TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException $e) { + } catch (RouteNotFoundException) { $uri = $uriBuilder->buildUriFromRoutePath($moduleName, $urlParameters); } return (string)$uri; diff --git a/Classes/Module/NewsAdminModule.php b/Classes/Module/NewsAdminModule.php index 278d29c..31110b0 100644 --- a/Classes/Module/NewsAdminModule.php +++ b/Classes/Module/NewsAdminModule.php @@ -24,13 +24,14 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - use Doctrine\DBAL\DBALException; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use RG\TtNews\Database\Database; use RG\TtNews\Utility\Div; use RG\TtNews\Utility\IconFactory; +use TYPO3\CMS\Backend\Routing\PreviewUriBuilder; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\DocumentTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\PageTreeView; @@ -42,6 +43,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Core\Utility\PathUtility; +use TYPO3\CMS\Core\Utility\StringUtility; /** * Module 'News Admin' for the 'tt_news' extension. @@ -50,8 +52,6 @@ * $Id$ * * @author Rupert Germann - * @package TYPO3 - * @subpackage tt_news */ class NewsAdminModule extends BaseScriptClass { @@ -67,11 +67,11 @@ class NewsAdminModule extends BaseScriptClass /** * @var array */ - public $markers = array(); + public $markers = []; /** * @var array */ - public $docHeaderButtons = array(); + public $docHeaderButtons = []; // list of selected category from GETpublics extended by subcategories /** * @var @@ -89,7 +89,7 @@ class NewsAdminModule extends BaseScriptClass /** * @var array */ - public $TSprop = array(); + public $TSprop = []; /** * @var string */ @@ -97,7 +97,7 @@ class NewsAdminModule extends BaseScriptClass /** * @var array */ - public $permsCache = array(); + public $permsCache = []; /** * @var int */ @@ -126,11 +126,11 @@ class NewsAdminModule extends BaseScriptClass /** * @var array */ - public $excludeCats = array(); + public $excludeCats = []; /** * @var array */ - public $includeCats = array(); + public $includeCats = []; /** * @var @@ -221,7 +221,6 @@ class NewsAdminModule extends BaseScriptClass */ public $sPageIcon; - /** * @var array */ @@ -246,10 +245,12 @@ public function __construct() $this->getLanguageService()->includeLLFile('EXT:tt_news/Classes/Module/locallang.xml'); - $this->getPageRenderer()->addCssFile('EXT:tt_news/Resources/Public/Css/BackendModule.css', 'stylesheet', - 'screen'); + $this->getPageRenderer()->addCssFile( + 'EXT:tt_news/Resources/Public/Css/BackendModule.css', + 'stylesheet', + 'screen' + ); $this->iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class); - } /** @@ -271,31 +272,31 @@ public function mainAction( /** * Initializes the Module * - * @return void * @throws DBALException */ public function init() { if (!$this->MCONF['name']) { $this->MCONF = $GLOBALS['MCONF']; - } $this->isAdmin = $this->getBackendUser()->isAdmin(); - $this->id = intval(GeneralUtility::_GP('id')); + $this->id = (int)(GeneralUtility::_GP('id')); $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1); $this->TSprop = BackendUtility::getPagesTSconfig($this->id)['mod.']['web_txttnewsM1.'] ?? []; $this->confArr = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['tt_news']; - $tceTSC = array(); + $tceTSC = []; if ($this->confArr['useStoragePid']) { - $tceTSC = BackendUtility::getTCEFORM_TSconfig('tt_news_cat', - array('pid' => $this->id)); + $tceTSC = BackendUtility::getTCEFORM_TSconfig( + 'tt_news_cat', + ['pid' => $this->id] + ); } - $this->storagePid = $tceTSC['_STORAGE_PID'] ? $tceTSC['_STORAGE_PID'] : $this->id; + $this->storagePid = $tceTSC['_STORAGE_PID'] ?: $this->id; - $localNewArticlePid = intval($this->TSprop['list.']['pidForNewArticles']); + $localNewArticlePid = (int)($this->TSprop['list.']['pidForNewArticles']); $this->newArticlePid = ($localNewArticlePid ?: $this->id); $this->script = 'mod.php?M=web_txttnewsM1'; @@ -314,14 +315,16 @@ public function init() $this->mayUserEditCategories = $this->grspCalcPerms & 16; // get pageinfo array for newArticlePid - $newArticlePidPI = BackendUtility::readPageAccess($this->newArticlePid, - $this->perms_clause); + $newArticlePidPI = BackendUtility::readPageAccess( + $this->newArticlePid, + $this->perms_clause + ); $this->newArticleCalcPerms = $this->getBackendUser()->calcPerms($newArticlePidPI); $this->mayUserEditArticles = $this->newArticleCalcPerms & 16; $pagesTSC = BackendUtility::getPagesTSconfig($this->id); if ($pagesTSC['tx_ttnews.']['singlePid']) { - $this->singlePid = intval($pagesTSC['tx_ttnews.']['singlePid']); + $this->singlePid = (int)($pagesTSC['tx_ttnews.']['singlePid']); } $this->initCategories(); @@ -335,16 +338,15 @@ public function init() $this->menuConfig(); $this->mData = $this->getBackendUser()->uc['moduleData']['web_txttnewsM1']; + $this->current_sys_language = (int)($this->MOD_SETTINGS['language']); + $this->searchLevels = (int)($this->MOD_SETTINGS['searchLevels']); + $this->thumbs = (int)($this->MOD_SETTINGS['showThumbs']); - $this->current_sys_language = intval($this->MOD_SETTINGS['language']); - $this->searchLevels = intval($this->MOD_SETTINGS['searchLevels']); - $this->thumbs = intval($this->MOD_SETTINGS['showThumbs']); - - $localLimit = intval($this->MOD_SETTINGS['showLimit']); + $localLimit = (int)($this->MOD_SETTINGS['showLimit']); if ($localLimit) { $this->showLimit = $localLimit; } else { - $this->showLimit = intval($this->TSprop['list.']['limit']); + $this->showLimit = (int)($this->TSprop['list.']['limit']); } $this->initGPvars(); @@ -359,7 +361,6 @@ public function init() */ public function main() { - $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('EXT:tt_news/Classes/Module/mod_ttnews_admin.html'); @@ -376,7 +377,6 @@ public function main() $access = (is_array($this->pageinfo) ? 1 : 0); $this->markers['MOD_INFO'] = ''; - if ($this->id && $access) { // JavaScript $this->doc->JScode = GeneralUtility::wrapJS(' @@ -396,7 +396,6 @@ function openFePreview(URL) { script_ended = 1; '); - // Render content: $this->moduleContent(); } else { @@ -419,7 +418,7 @@ function openFePreview(URL) { $this->content = $this->doc->insertStylesAndJS($this->content); if (count($this->permsCache)) { - $this->getBackendUser()->setAndSaveSessionData('permsCache', array($this->pidChash => $this->permsCache)); + $this->getBackendUser()->setAndSaveSessionData('permsCache', [$this->pidChash => $this->permsCache]); } } @@ -437,11 +436,9 @@ public function printContent(): string * ************************************************************************/ - /** * Generates the module content * - * @return void * @throws DBALException * @throws SiteNotFoundException */ @@ -451,8 +448,11 @@ public function moduleContent() $this->table = 'tt_news_cat'; if ($this->confArr['useStoragePid']) { - $catRows = Database::getInstance()->exec_SELECTgetRows('uid', 'tt_news_cat', - 'pid=' . $this->storagePid . $this->catlistWhere . ' AND deleted=0'); + $catRows = Database::getInstance()->exec_SELECTgetRows( + 'uid', + 'tt_news_cat', + 'pid=' . $this->storagePid . $this->catlistWhere . ' AND deleted=0' + ); if (empty($catRows)) { $error = $this->displayOverview(); @@ -460,14 +460,12 @@ public function moduleContent() } if (!$error) { - - // fixme: throws JS errors, commented out -// $this->doc->getDragDropCode('tt_news_cat'); -// $this->doc->postCode=GeneralUtility::wrapJS(' -// txttnewsM1js.registerDragDropHandlers(); -// '); -// $this->getPageRenderer()->loadJquery(); + // $this->doc->getDragDropCode('tt_news_cat'); + // $this->doc->postCode=GeneralUtility::wrapJS(' + // txttnewsM1js.registerDragDropHandlers(); + // '); + // $this->getPageRenderer()->loadJquery(); $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu'); $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/TtNews/NewsBackendModule'); @@ -482,10 +480,12 @@ public function moduleContent() */ public function displayOverview() { - $tRows = array(); + $tRows = []; $tRows[] = ' -

+

' . $this->getLanguageService()->getLL('nothingfound') . '


'; @@ -496,7 +496,7 @@ public function displayOverview() 'pid>=0' . $this->catlistWhere . ' AND deleted = 0', 'pid' ); - $list = array(); + $list = []; while (($row = Database::getInstance()->sql_fetch_assoc($res))) { $list[$row['pid']]['count'] = $row['count(uid)']; } @@ -513,27 +513,28 @@ public function displayOverview() if ($pa['path']) { $tRows[] = ' - ' . htmlspecialchars($pa['path']) . ' - ' . htmlspecialchars($stat['count']) . ' + ' . htmlspecialchars((string)$pa['path']) . ' + ' . htmlspecialchars((string)$stat['count']) . ' '; } } // Create overview - $outputString = '' . implode('', - $tRows) . '
'; + $outputString = '' . implode( + '', + $tRows + ) . '
'; // Add output: $this->markers['MOD_INFO'] = $outputString; return true; - } - - /** * @return string * @throws DBALException @@ -580,17 +581,19 @@ public function getTreeObj() $this->treeObj = GeneralUtility::makeInstance(CategoryManager::class); } - $urlparams = array('id' => $this->id); + $urlparams = ['id' => $this->id]; $this->treeObj->table = 'tt_news_cat'; $this->treeObj->init($this->catlistWhere . $addWhere, $treeOrderBy); $this->treeObj->parentField = 'parent_category'; $this->treeObj->thisScript = $this->script . '&id=' . $this->id; - $this->treeObj->returnUrl = LegacyBackendUtility::getModuleUrl('web_txttnewsM1', - $urlparams); + $this->treeObj->returnUrl = LegacyBackendUtility::getModuleUrl( + 'web_txttnewsM1', + $urlparams + ); // those fields will be filled to the array $this->treeObj->tree - $this->treeObj->fieldArray = array('uid', 'title', 'description', 'hidden', 'starttime', 'endtime', 'fe_group'); + $this->treeObj->fieldArray = ['uid', 'title', 'description', 'hidden', 'starttime', 'endtime', 'fe_group']; $this->treeObj->mayUserEditCategories = $this->mayUserEditCategories; $this->treeObj->title = $this->getLanguageService()->getLL('treeTitle'); $this->treeObj->pageID = $this->id; @@ -620,11 +623,15 @@ public function getTreeObj() // get all selected category records from the current storagePid which are not 'root' categories // and add them as tree mounts. Subcategories of selected categories will be excluded. - $cMounts = array(); + $cMounts = []; $nonRootMounts = false; foreach ($beUserSelCatArr as $catID) { - $tmpR = BackendUtility::getRecord('tt_news_cat', $catID, - 'parent_category,hidden', $addWhere); + $tmpR = BackendUtility::getRecord( + 'tt_news_cat', + $catID, + 'parent_category,hidden', + $addWhere + ); if (is_array($tmpR) && !in_array($catID, $subcatArr)) { if ($tmpR['parent_category'] > 0) { $nonRootMounts = true; @@ -644,7 +651,6 @@ public function getTreeObj() /** * returns the root element for a category tree: icon, title and pageID - * */ protected function getStoragePageIcon() { @@ -654,10 +660,12 @@ protected function getStoragePageIcon() $rootRec = $this->treeObj->getRecord($this->storagePid); $icon = $this->treeObj->getIcon($rootRec); $this->treeObj->table = $tmpt; - $pidLbl = sprintf($this->getLanguageService()->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xlf:tt_news.treeSelect.pageTitleSuffix'), - $this->storagePid); + $pidLbl = sprintf( + $this->getLanguageService()->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xlf:tt_news.treeSelect.pageTitleSuffix'), + $this->storagePid + ); } else { - $rootRec = $this->treeObj->getRootRecord($this->storagePid); + $rootRec = $this->treeObj->getRootRecord(); $icon = $this->treeObj->getRootIcon($rootRec); $pidLbl = $this->getLanguageService()->sL('LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xlf:tt_news.treeSelect.pageTitleSuffixNoGrsp'); } @@ -681,6 +689,7 @@ protected function getStoragePageIcon() */ public function displayNewsList($ajax = false) { + $externalTables = []; $content = ''; $this->initSubCategories(); @@ -690,7 +699,7 @@ public function displayNewsList($ajax = false) /* @var $dblist NewsRecordlist */ $dblist = GeneralUtility::makeInstance(NewsRecordlist::class); - $urlparams = array('id' => $this->id); + $urlparams = ['id' => $this->id]; if (GeneralUtility::_GP('category') != '') { $urlparams['category'] = (int)GeneralUtility::_GP('category'); } @@ -731,7 +740,7 @@ public function displayNewsList($ajax = false) $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->searchLevels, $this->showLimit); if ($this->searchLevels > 0) { $allowedMounts = $this->getSearchableWebmounts($this->id, $this->searchLevels, $this->perms_clause); - $pidList = implode(',',$allowedMounts); + $pidList = implode(',', $allowedMounts); $dblist->pidSelect = 'pid IN (' . $pidList . ')'; } elseif ($this->searchLevels < 0) { // Search everywhere @@ -760,7 +769,7 @@ public function displayNewsList($ajax = false) $content .= $this->getListHeaderMsg($dblist); $content .= $dblist->HTMLcode; - $content = '
' . $content . '
'; + $content = '
' . $content . '
'; return '
' . $content . '
'; } @@ -803,7 +812,6 @@ protected function getSearchableWebmounts($id, $depth, $perms_clause) ************************************************************************/ /** - * * @throws DBALException */ public function ajaxExpandCollapse($params) @@ -813,7 +821,7 @@ public function ajaxExpandCollapse($params) $this->getTreeObj(); $tree = $this->treeObj->getBrowsableTree(); - return $tree; + return $tree; } /** @@ -830,8 +838,6 @@ public function ajaxLoadList($params) return $list; } - /** - */ public function processAjaxRequestConstruct() { global $SOBE; @@ -850,7 +856,6 @@ public function processAjaxRequestConstruct() ************************************************************************/ /** - * * @param NewsRecordlist $dblist * * @return string @@ -858,12 +863,13 @@ public function processAjaxRequestConstruct() */ protected function getListHeaderMsg(&$dblist): string { - $noCatSelMsg = false; if (!$this->selectedCategories) { if ($this->TSprop['list.']['noListWithoutCatSelection']) { - $content = '' . $this->getLanguageService()->getLL('selectCategory'); + $content = '' . $this->getLanguageService()->getLL('selectCategory'); $noCatSelMsg = true; } else { $content = $this->getLanguageService()->getLL('showingAll'); @@ -887,18 +893,21 @@ protected function getListHeaderMsg(&$dblist): string protected function displaySearch($url): string { // Table with the search box: - return '
+ return ' - - - + + + @@ -914,7 +923,7 @@ protected function displaySearch($url): string protected function getNoResultsMsg(&$listObj, $noCatSelMsg) { $content = ''; - $tRows = array(); + $tRows = []; if (!$noCatSelMsg) { $tRows[] = '

@@ -923,39 +932,45 @@ protected function getNoResultsMsg(&$listObj, $noCatSelMsg) '; } - if ($this->mayUserEditArticles) { $tRows[] = '

' . $listObj->getNewRecordButton('tt_news', true) . '
'; } - return $content . '' . implode('', - $tRows) . '
'; + return $content . '' . implode( + '', + $tRows + ) . '
'; } - /** * @return string */ protected function renderTreeCheckBoxes() { - $show = array(); + $show = []; if (is_array($this->TSprop['catmenu.']['show.'])) { $show = $this->TSprop['catmenu.']['show.']; } - $allowedCbNames = array('expandAll', 'showHiddenCategories'); + $allowedCbNames = ['expandAll', 'showHiddenCategories']; if ($this->mayUserEditCategories) { $allowedCbNames[] = 'showEditIcons'; } $params = $this->getLinkParams(); - $out = array(); + $out = []; foreach ($allowedCbNames as $n) { if ((bool)$show['cb_' . $n]) { - $out[] = BackendUtility::getFuncCheck($params, 'SET[' . $n . ']', - $this->MOD_SETTINGS[$n], '', '', 'id="cb-' . $n . '"') . + $out[] = BackendUtility::getFuncCheck( + $params, + 'SET[' . $n . ']', + $this->MOD_SETTINGS[$n], + '', + '', + 'id="cb-' . $n . '"' + ) . ' '; } } @@ -970,11 +985,11 @@ protected function renderTreeCheckBoxes() */ protected function renderListCheckBoxes($ajax = false) { - $show = array(); + $show = []; if (is_array($this->TSprop['list.']['show.'])) { $show = $this->TSprop['list.']['show.']; } - $allowedCbNames = array(); + $allowedCbNames = []; if (GeneralUtility::inList($this->fieldList, 'image')) { $allowedCbNames[] = 'showThumbs'; } @@ -983,7 +998,7 @@ protected function renderListCheckBoxes($ajax = false) } $params = $this->getLinkParams(); - $out = array(); + $out = []; $savedRoute = false; if ($ajax) { @@ -993,8 +1008,14 @@ protected function renderListCheckBoxes($ajax = false) foreach ($allowedCbNames as $n) { if ((bool)$show['cb_' . $n]) { $out[] = '' . - BackendUtility::getFuncCheck($params, 'SET[' . $n . ']', - $this->MOD_SETTINGS[$n], '', '', 'id="cb-' . $n . '"') . + BackendUtility::getFuncCheck( + $params, + 'SET[' . $n . ']', + $this->MOD_SETTINGS[$n], + '', + '', + 'id="cb-' . $n . '"' + ) . ' '; } } @@ -1005,21 +1026,19 @@ protected function renderListCheckBoxes($ajax = false) return '
' . implode('', $out) . '
'; } - /** * @return string */ protected function renderNewCatButton() { - $show = array(); + $show = []; $button = ''; if (is_array($this->TSprop['catmenu.']['show.'])) { $show = $this->TSprop['catmenu.']['show.']; } if ($this->mayUserEditCategories && (bool)$show['btn_newCategory']) { $params = '&edit[tt_news_cat][' . $this->storagePid . ']=new'; - $onclick = htmlspecialchars(BackendUtility::editOnClick($params, - $GLOBALS['BACK_PATH'], $this->returnUrl)); + $onclick = htmlspecialchars(GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit') . $params . '&returnUrl=' . rawurlencode((string)GeneralUtility::getIndpEnv('REQUEST_URI'))); /** * @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory */ @@ -1033,7 +1052,6 @@ protected function renderNewCatButton() return '
' . $button . '
'; } - /** * Create the panel of buttons for submitting the form or otherwise perform operations. * @@ -1042,7 +1060,7 @@ protected function renderNewCatButton() protected function getHeaderButtons() { $lang = $this->getLanguageService(); - $buttons = array( + $buttons = [ 'csh' => '', 'view' => '', 'edit' => '', @@ -1052,27 +1070,26 @@ protected function getHeaderButtons() 'shortcut' => '', 'back' => '', 'csv' => '', - 'export' => '' - ); + 'export' => '', + ]; $backPath = $GLOBALS['BACK_PATH']; if (isset($this->id)) { if ($this->getBackendUser()->check('modules', 'web_list')) { - $href = LegacyBackendUtility::getModuleUrl('web_list', array( + $href = LegacyBackendUtility::getModuleUrl('web_list', [ 'id' => $this->pageinfo['uid'], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') - )); + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), + ]); - $buttons['record_list'] = '' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . ''; } // View - $buttons['view'] = '' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . ''; @@ -1081,29 +1098,35 @@ protected function getHeaderButtons() if ($this->localCalcPerms & 2 && !empty($this->id)) { // Edit $params = '&edit[pages][' . $this->pageinfo['uid'] . ']=edit'; - $buttons['edit'] = '' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . ''; } // Reload - $buttons['reload'] = '' . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . ''; // Shortcut if ($this->getBackendUser()->mayMakeShortcut()) { - $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, showThumbs, pointer, table, search_field, searchLevels, showLimit, sortField, sortRev', - implode(',', array_keys($this->MOD_MENU)), 'web_txttnewsM1', '', 'btn btn-default btn-sm'); + $buttons['shortcut'] = $this->doc->makeShortcutIcon( + 'id, showThumbs, pointer, table, search_field, searchLevels, showLimit, sortField, sortRev', + implode(',', array_keys($this->MOD_MENU)), + 'web_txttnewsM1', + '', + 'btn btn-default btn-sm' + ); } // Back if ($this->returnUrl) { - $buttons['back'] = 'returnUrl, + ['id' => $this->id] + )) . '" class="typo3-goBack btn btn-default btn-sm" title="' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack')) . '">' . $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . ''; @@ -1113,18 +1136,22 @@ protected function getHeaderButtons() return $buttons; } - /** * @return string */ protected function getLangMenu() { $menu = ''; - if (count($this->MOD_MENU['language']) > 1) { - $menu = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', - 1) . - BackendUtility::getFuncMenu($this->id, 'SET[language]', - $this->current_sys_language, $this->MOD_MENU['language']); + if ((is_countable($this->MOD_MENU['language']) ? count($this->MOD_MENU['language']) : 0) > 1) { + $menu = $this->getLanguageService()->sL( + 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language' + ) . + BackendUtility::getFuncMenu( + $this->id, + 'SET[language]', + $this->current_sys_language, + $this->MOD_MENU['language'] + ); } return $menu; @@ -1136,10 +1163,14 @@ protected function getLangMenu() protected function getPageSelector() { $menu = ''; - if (count($this->MOD_MENU['searchLevels']) > 1) { + if ((is_countable($this->MOD_MENU['searchLevels']) ? count($this->MOD_MENU['searchLevels']) : 0) > 1) { $menu = $this->getLanguageService()->getLL('enterSearchLevels') . - BackendUtility::getFuncMenu($this->id, 'SET[searchLevels]', - $this->searchLevels, $this->MOD_MENU['searchLevels']); + BackendUtility::getFuncMenu( + $this->id, + 'SET[searchLevels]', + $this->searchLevels, + $this->MOD_MENU['searchLevels'] + ); } return $menu; @@ -1173,8 +1204,8 @@ protected function setPidList() $pidList .= ',' . $mount . ',' . $this->getSubPages($mount); } - $pidList = GeneralUtility::uniqueList($pidList); - $this->pidList = ($pidList ? $pidList : 0); + $pidList = StringUtility::uniqueList($pidList); + $this->pidList = ($pidList ?: 0); } /** @@ -1182,8 +1213,8 @@ protected function setPidList() */ protected function setEditablePages($pidlist) { - $pids = explode(',', $pidlist); - $editPids = array(); + $pids = explode(',', (string)$pidlist); + $editPids = []; foreach ($pids as $pid) { if (($this->checkPageAccess($pid))) { @@ -1195,7 +1226,6 @@ protected function setEditablePages($pidlist) } /** - * * @param $pages * @param int $cc * @@ -1204,11 +1234,12 @@ protected function setEditablePages($pidlist) */ protected function getSubPages($pages, $cc = 0) { - $pArr = array(); + $pArr = []; $res = Database::getInstance()->exec_SELECTquery( 'uid', 'pages', - 'pages.pid IN (' . $pages . ') AND pages.deleted=0 AND ' . $this->perms_clause); + 'pages.pid IN (' . $pages . ') AND pages.deleted=0 AND ' . $this->perms_clause + ); while (($row = Database::getInstance()->sql_fetch_assoc($res))) { $cc++; @@ -1227,16 +1258,15 @@ protected function getSubPages($pages, $cc = 0) return implode(',', $pArr); } - /** - * - */ protected function initGPvars() { - $this->pointer = MathUtility::forceIntegerInRange(GeneralUtility::_GP('pointer'), - 0, 100000); - $this->category = intval(GeneralUtility::_GP('category')); + $this->pointer = MathUtility::forceIntegerInRange( + GeneralUtility::_GP('pointer'), + 0, + 100000 + ); + $this->category = (int)(GeneralUtility::_GP('category')); $this->search_field = GeneralUtility::_GP('search_field'); - } /** @@ -1246,38 +1276,46 @@ protected function initGPvars() */ public function menuConfig() { - $this->MOD_MENU = array( - 'function' => array( + $this->MOD_MENU = [ + 'function' => [ '1' => $this->getLanguageService()->getLL('function1'), - ), + ], 'showEditIcons' => 0, 'expandAll' => 0, 'showOnlyEditable' => 0, 'showHiddenCategories' => 0, - 'searchLevels' => array( + 'searchLevels' => [ -1 => $this->getLanguageService()->getLL('allPages'), 0 => $this->getLanguageService()->getLL('thisPage'), 1 => $this->getLanguageService()->getLL('oneLevel'), 2 => $this->getLanguageService()->getLL('twoLevels'), 3 => $this->getLanguageService()->getLL('threeLevels'), - 4 => $this->getLanguageService()->getLL('fourLevels') + 4 => $this->getLanguageService()->getLL('fourLevels'), - ), + ], 'showThumbs' => 1, 'showLimit' => 0, - 'language' => array( - 0 => $this->getLanguageService()->getLL('defaultLangLabel') - ) + 'language' => [ + 0 => $this->getLanguageService()->getLL('defaultLangLabel'), + ], - ); + ]; $this->initLanguageMenu(); - $this->MOD_MENU['function'] = $this->mergeExternalItems($this->MCONF['name'], 'function', - $this->MOD_MENU['function']); + $this->MOD_MENU['function'] = $this->mergeExternalItems( + $this->MCONF['name'], + 'function', + $this->MOD_MENU['function'] + ); - $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, - GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, - $this->modMenu_dontValidateList, $this->modMenu_setDefaultList); + $this->MOD_SETTINGS = BackendUtility::getModuleData( + $this->MOD_MENU, + GeneralUtility::_GP('SET'), + $this->MCONF['name'], + $this->modMenu_type, + $this->modMenu_dontValidateList, + $this->modMenu_setDefaultList + ); } /** @@ -1314,13 +1352,12 @@ protected function initLanguageMenu() $this->MOD_MENU['language'][-1] = $this->getLanguageService()->getLL('allLanguages'); // Setting alternative default label: - $dl = trim($this->TSprop['defaultLanguageLabel']); + $dl = trim((string)$this->TSprop['defaultLanguageLabel']); if ($dl && isset($this->MOD_MENU['language'][0])) { $this->MOD_MENU['language'][0] = $dl; } } - /** * @throws DBALException */ @@ -1347,7 +1384,7 @@ protected function initCategories() protected function posIntExplode($list) { $arr = GeneralUtility::intExplode(',', $list); - $out = array(); + $out = []; foreach ($arr as $v) { if ($v > 0) { @@ -1359,14 +1396,13 @@ protected function posIntExplode($list) } /** - * * @throws DBALException */ protected function initSubCategories() { if ($this->useSubCategories && $this->category) { $subcats = Div::getSubCategories($this->category); - $this->selectedCategories = GeneralUtility::uniqueList($this->category . ($subcats ? ',' . $subcats : '')); + $this->selectedCategories = StringUtility::uniqueList($this->category . ($subcats ? ',' . $subcats : '')); } else { $this->selectedCategories = $this->category; } @@ -1376,13 +1412,13 @@ protected function initSubCategories() * Checks if a PID value is accessible and if so returns the path for the page. * Processing is cached so many calls to the function are OK. * - * @param integer Page id for check + * @param int Page id for check * * @return array Page path of PID if accessible. otherwise zero. */ protected function getPageInfoForOverview($pid) { - $out = array(); + $out = []; $localPageinfo = BackendUtility::readPageAccess($pid, $this->perms_clause); $out['path'] = $localPageinfo['_thePath']; @@ -1405,8 +1441,10 @@ public function checkPageAccess($pid) return $this->permsCache[$pid]; } - $calcPerms = $this->getBackendUser()->calcPerms(BackendUtility::readPageAccess($pid, - $this->perms_clause)); + $calcPerms = $this->getBackendUser()->calcPerms(BackendUtility::readPageAccess( + $pid, + $this->perms_clause + )); if (($calcPerms & 16)) { $this->permsCache[$pid] = true; } else { @@ -1416,9 +1454,6 @@ public function checkPageAccess($pid) return $this->permsCache[$pid]; } - /** - * - */ protected function initPermsCache() { if ($this->isAdmin) { @@ -1437,7 +1472,7 @@ protected function initPermsCache() */ protected function getLinkParams() { - $params = array('id' => $this->id); + $params = ['id' => $this->id]; if ($this->category) { $params['category'] = $this->category; @@ -1447,22 +1482,24 @@ protected function getLinkParams() } /** - * * @return string * @throws DBALException */ protected function getListHeaderMsgForSelectedCategories(): string { + $element = null; $table = 'tt_news_cat'; $row = BackendUtility::getRecord($table, $this->category); $title = '' . BackendUtility::getRecordTitle($table, $row) . ''; $content = '
' . $this->getLanguageService()->getLL('showingOnlyCat') . $title . '
'; - if ($this->useSubCategories && ($subCats = GeneralUtility::rmFromList($this->category, - $this->selectedCategories))) { - $scRows = Database::getInstance()->exec_SELECTgetRows('uid,title,hidden', $table, - 'uid IN (' . $subCats . ')' . (!$this->mData['showHiddenCategories'] ? ' AND hidden=0' : '')); - $scTitles = array(); + if ($this->useSubCategories && ($subCats = implode(',', array_filter(explode(',', (string)$this->selectedCategories), fn($item) => $element == $item)))) { + $scRows = Database::getInstance()->exec_SELECTgetRows( + 'uid,title,hidden', + $table, + 'uid IN (' . $subCats . ')' . (!$this->mData['showHiddenCategories'] ? ' AND hidden=0' : '') + ); + $scTitles = []; foreach ($scRows as $scRow) { $recTitle = BackendUtility::getRecordTitle($table, $scRow); if ($scRow['hidden']) { @@ -1490,5 +1527,3 @@ protected function getListHeaderMsgForSelectedCategories(): string return $content; } } - - diff --git a/Classes/Module/NewsRecordlist.php b/Classes/Module/NewsRecordlist.php index 4d83a9d..a2f08d7 100644 --- a/Classes/Module/NewsRecordlist.php +++ b/Classes/Module/NewsRecordlist.php @@ -27,9 +27,10 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - +use Doctrine\DBAL\DBALException; use RG\TtNews\Database\Database; use RG\TtNews\Utility\IconFactory; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -39,14 +40,10 @@ * * * @author Rupert Germann - * @package TYPO3 - * @subpackage tt_news */ /** * Class NewsRecordlist - * - * @package RG\TtNews\Module */ class NewsRecordlist extends PageLayoutView { @@ -123,13 +120,11 @@ class NewsRecordlist extends PageLayoutView */ protected $disableSingleTableView; - /********************************** * * Generic listing of items * **********************************/ - /** * Creates a standard list of elements from a table. * @@ -140,16 +135,21 @@ class NewsRecordlist extends PageLayoutView * @param string Additional WHERE-clauses. * * @return string HTML table - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') { + $newRecIcon = null; + $result = null; // Initialize: $out = ''; $queryParts = $this->makeQueryArray($table, $id, $addWhere); //TODO: Make use of $this->setTotalItems instead of this "plain" query! - $this->totalItems = Database::getInstance()->exec_SELECTcountRows('*', $queryParts['FROM'], - $queryParts['WHERE']); + $this->totalItems = Database::getInstance()->exec_SELECTcountRows( + '*', + $queryParts['FROM'], + $queryParts['WHERE'] + ); $this->eCounter = 0; // Make query for records if there were any records found in the count operation: @@ -166,7 +166,7 @@ public function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') $this->fieldArray = explode(',', $fList); // Header line is drawn - $theData = array(); + $theData = []; $theData = $this->headerFields($this->fieldArray, $table, $theData); if ($this->doEdit) { $newRecIcon = $this->getNewRecordButton($table); @@ -175,7 +175,7 @@ public function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') $out .= $this->addelement(1, $newRecIcon, $theData, ' class="c-headLineTable"'); $checkCategories = false; - if (count($this->includeCats) || count($this->excludeCats)) { + if ((is_countable($this->includeCats) ? count($this->includeCats) : 0) || (is_countable($this->excludeCats) ? count($this->excludeCats) : 0)) { $checkCategories = true; } @@ -188,7 +188,7 @@ public function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') continue; } - $Nrow = array(); + $Nrow = []; $NrowIcon = ''; $noEdit = $this->checkRecordPerms($row, $checkCategories); @@ -199,10 +199,11 @@ public function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') if (!$noEdit) { $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; - $NrowIcon .= '' . - '' . + $NrowIcon .= '' . + '' . ''; } else { $NrowIcon .= $this->noEditIcon($noEdit); @@ -292,8 +293,11 @@ protected function renderListNavigation() $last = ''; } - $pageIndicator = sprintf($GLOBALS['LANG']->sL('LLL:EXT:tt_news/Classes/Module/locallang.xml:pageIndicator'), - $currentPage, $totalPages); + $pageIndicator = sprintf( + $GLOBALS['LANG']->sL('LLL:EXT:tt_news/Classes/Module/locallang.xml:pageIndicator'), + $currentPage, + $totalPages + ); if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) { $lastElementNumber = $this->firstElementNumber + $this->iLimit; @@ -301,8 +305,12 @@ protected function renderListNavigation() $lastElementNumber = $this->totalItems; } $rangeIndicator = '' - . sprintf($GLOBALS['LANG']->sL('LLL:EXT:tt_news/Classes/Module/locallang.xml:rangeIndicator'), - $this->firstElementNumber + 1, $lastElementNumber, $this->totalItems) + . sprintf( + $GLOBALS['LANG']->sL('LLL:EXT:tt_news/Classes/Module/locallang.xml:rangeIndicator'), + $this->firstElementNumber + 1, + $lastElementNumber, + $this->totalItems + ) . ''; $content .= '
' @@ -314,11 +322,11 @@ protected function renderListNavigation() . '
'; } // end of if pages > 1 - $data = Array(); + $data = []; $titleColumn = $this->fieldArray[0]; $data[$titleColumn] = $content; - return ($this->addElement(1, '', $data)); + return $this->addElement(1, '', $data); } /** @@ -336,7 +344,7 @@ protected function renderListNavigation() * @return array $out array returned after processing. * @see makeOrdinaryList() */ - public function dataFields($fieldArr, $table, $row, $out = array(), $noEdit = false) + public function dataFields($fieldArr, $table, $row, $out = [], $noEdit = false) { global $TCA; @@ -351,44 +359,64 @@ public function dataFields($fieldArr, $table, $row, $out = array(), $noEdit = fa // Traverse fields: foreach ($fieldArr as $fieldName) { - if ($TCA[$table]['columns'][$fieldName]) { // Each field has its own cell (if configured in TCA) if ($fieldName == $thumbsCol) { // If the column is a thumbnail column: if ($this->thumbs) { - $val = BackendUtility::thumbCode($row, $table, $fieldName, - $this->backPath, $this->thumbScript, null, 0, '', $thumbsize); + $val = BackendUtility::thumbCode( + $row, + $table, + $fieldName, + $this->backPath, + $this->thumbScript, + null, + 0, + '', + $thumbsize + ); } else { - $val = str_replace(',', ', ', basename($row[$fieldName])); + $val = str_replace(',', ', ', basename((string)$row[$fieldName])); } } else { // ... otherwise just render the output: - $val = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(BackendUtility::getProcessedValue($table, - $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']), 250)))); + $val = nl2br(htmlspecialchars(trim((string)GeneralUtility::fixed_lgd_cs(BackendUtility::getProcessedValue( + $table, + $fieldName, + $row[$fieldName], + 0, + 0, + 0, + $row['uid'] + ), 250)))); if ($this->lTSprop['clickTitleMode'] == 'view' && $this->singlePid) { $val = $this->linkSingleView($url, $val, $row['uid']); } elseif ($this->lTSprop['clickTitleMode'] == 'edit' && !$noEdit) { $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; - $lTitle = ' title="' . $GLOBALS['LANG']->getLL('edit', 1) . '"'; - $val = '' . $val . ''; + $lTitle = ' title="' . htmlspecialchars((string)$GLOBALS['LANG']->getLL('edit')) . '"'; + $val = '' . $val . ''; } } $out[$fieldName] = $val; } else { // Each field is separated by
and shown in the same cell (If not a TCA field, then explode the field name with ";" and check each value there as a TCA configured field) - $theFields = explode(';', $fieldName); + $theFields = explode(';', (string)$fieldName); // Traverse fields, separated by ";" (displayed in a single cell). foreach ($theFields as $fName2) { if ($TCA[$table]['columns'][$fName2]) { - $out[$fieldName] .= '' . $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'], - 1) . '' . + $out[$fieldName] .= '' . htmlspecialchars((string)$GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'])) . '' . '  ' . - htmlspecialchars(GeneralUtility::fixed_lgd_cs(BackendUtility::getProcessedValue($table, - $fName2, $row[$fName2], 0, 0, 0, $row['uid']), 25)) . + htmlspecialchars((string)GeneralUtility::fixed_lgd_cs(BackendUtility::getProcessedValue( + $table, + $fName2, + $row[$fName2], + 0, + 0, + 0, + $row['uid'] + ), 25)) . '
'; } } @@ -417,14 +445,14 @@ public function dataFields($fieldArr, $table, $row, $out = array(), $noEdit = fa */ protected function linkSingleView($url, $val, $uid) { - $params = array( + $params = [ 'id' => $this->singlePid, 'tx_ttnews[tt_news]' => $uid, - 'no_cache' => 1 - ); + 'no_cache' => 1, + ]; $linkedurl = GeneralUtility::linkThisUrl($url, $params); - $onclick = 'openFePreview(\'' . htmlspecialchars($linkedurl) . '\');'; - $lTitle = $GLOBALS['LANG']->getLL('openFePreview', 1); + $onclick = 'openFePreview(\'' . htmlspecialchars((string)$linkedurl) . '\');'; + $lTitle = htmlspecialchars((string)$GLOBALS['LANG']->getLL('openFePreview')); return '' . $val . ''; } @@ -437,14 +465,15 @@ protected function linkSingleView($url, $val, $uid) */ public function getNewRecordButton($table, $withLabel = false) { + $addP = null; + $addLbl = null; if ($this->category) { $addP = '&defVals[' . $table . '][category]=' . $this->category; $addLbl = 'InCategory'; } $params = '&edit[' . $table . '][' . $this->newRecPid . ']=new' . $addP; - $onclick = htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, - $this->returnUrl)); + $onclick = htmlspecialchars(GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit') . $params . '&returnUrl=' . rawurlencode((string)GeneralUtility::getIndpEnv('REQUEST_URI'))); /** * @var IconFactory $iconFactory @@ -457,7 +486,6 @@ public function getNewRecordButton($table, $withLabel = false) ''; } - /** * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu. * @@ -485,8 +513,7 @@ public function getIcon($table, $row, $noEdit = '') } // The icon with link - return BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid'], '', '', - $disableList); + return BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']); } /** @@ -494,7 +521,7 @@ public function getIcon($table, $row, $noEdit = '') * @param $checkCategories * * @return int - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ public function checkRecordPerms(&$row, $checkCategories) { @@ -513,11 +540,14 @@ public function checkRecordPerms(&$row, $checkCategories) $res = Database::getInstance()->exec_SELECTquery( 'tt_news_cat_mm.*', 'tt_news_cat_mm, tt_news_cat', - 'tt_news_cat_mm.uid_foreign=tt_news_cat.uid AND tt_news_cat.deleted=0 AND tt_news_cat_mm.uid_local=' . $row['uid']); + 'tt_news_cat_mm.uid_foreign=tt_news_cat.uid AND tt_news_cat.deleted=0 AND tt_news_cat_mm.uid_local=' . $row['uid'] + ); while (($mmrow = Database::getInstance()->sql_fetch_assoc($res))) { - if (!in_array($mmrow['uid_foreign'], $this->includeCats) || in_array($mmrow['uid_foreign'], - $this->excludeCats)) { + if (!in_array($mmrow['uid_foreign'], $this->includeCats) || in_array( + $mmrow['uid_foreign'], + $this->excludeCats + )) { $noEdit = 2; break; } @@ -537,25 +567,17 @@ public function checkRecordPerms(&$row, $checkCategories) */ public function noEditIcon($reason = 'noEditItems') { - switch ($reason) { - case 1: - $label = $GLOBALS['LANG']->getLL('noEditPagePerms', 1); - break; - - case 2: - $label = $GLOBALS['LANG']->getLL('noEditCategories', 1); - break; - default: - $label = ''; - break; - } + $label = match ($reason) { + 1 => htmlspecialchars((string)$GLOBALS['LANG']->getLL('noEditPagePerms')), + 2 => htmlspecialchars((string)$GLOBALS['LANG']->getLL('noEditCategories')), + default => '', + }; $img = 'noedit_' . $reason . '.gif'; return ''; } - /** * Header fields made for the listing of records * @@ -566,14 +588,17 @@ public function noEditIcon($reason = 'noEditItems') * @return array $out returned after addition of the header fields. * @see makeOrdinaryList() */ - public function headerFields($fieldArr, $table, $out = array()) + public function headerFields($fieldArr, $table, $out = []) { global $TCA; foreach ($fieldArr as $fieldName) { - $ll = $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fieldName]['label'], 1); - $out[$fieldName] = '' . ($ll ? $this->addSortLink($ll, $fieldName, - $table) : ' ') . ''; + $ll = htmlspecialchars((string)$GLOBALS['LANG']->sL($TCA[$table]['columns'][$fieldName]['label'])); + $out[$fieldName] = '' . ($ll ? $this->addSortLink( + $ll, + $fieldName, + $table + ) : ' ') . ''; } return $out; @@ -592,7 +617,6 @@ public function headerFields($fieldArr, $table, $out = array()) */ public function addSortLink($code, $field, $table) { - // Certain circumstances just return string right away (no links): if ($field == '_CONTROL_' || $field == '_LOCALIZATION_' || $field == '_CLIPBOARD_' || $field == '_REF_' || $this->disableSingleTableView) { return $code; @@ -604,8 +628,11 @@ public function addSortLink($code, $field, $table) } // Create the sort link: - $sortUrl = $this->listURL('', false, - 'sortField,sortRev') . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || ($this->sortField != $field) ? 0 : 1); + $sortUrl = $this->listURL( + '', + false, + 'sortField,sortRev' + ) . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || ($this->sortField != $field) ? 0 : 1); $sortArrow = ($this->sortField == $field ? 'sortRev ? 'up' : 'down') . '.gif', 'width="7" height="4"') . ' alt="" />' : ''); // Return linked field: @@ -634,10 +661,14 @@ public function listURL($altId = '', $table = '', $exclList = '') ($this->searchLevels ? '&searchLevels=' . rawurlencode($this->searchLevels) : '') . ($this->showLimit ? '&showLimit=' . rawurlencode($this->showLimit) : '') . ($this->firstElementNumber ? '&pointer=' . rawurlencode($this->firstElementNumber) : '') . - ((!$exclList || !GeneralUtility::inList($exclList, - 'sortField')) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '') . - ((!$exclList || !GeneralUtility::inList($exclList, - 'sortRev')) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '') . + ((!$exclList || !GeneralUtility::inList( + $exclList, + 'sortField' + )) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '') . + ((!$exclList || !GeneralUtility::inList( + $exclList, + 'sortRev' + )) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '') . ($this->category ? '&category=' . $this->category : ''); } @@ -648,10 +679,11 @@ public function listURL($altId = '', $table = '', $exclList = '') * @param string $fieldList * * @return array - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ - public function makeQueryArray($table, $id, $addWhere = "", $fieldList = '') + public function makeQueryArray($table, $id, $addWhere = '', $fieldList = '') { + $leftjoin = null; global $TCA; if (!$fieldList) { $fieldList = $table . '.*'; @@ -676,7 +708,6 @@ public function makeQueryArray($table, $id, $addWhere = "", $fieldList = '') // Adding search constraints: $search = $this->makeSearchString($table); - if ($this->selectedCategories) { $mmTable = 'tt_news_cat_mm'; $fieldList = 'DISTINCT ' . $table . '.uid, ' . $fieldList; @@ -705,7 +736,7 @@ public function makeQueryArray($table, $id, $addWhere = "", $fieldList = '') $addWhere .= ' AND ' . $table . '.sys_language_uid=' . $this->current_sys_language; // Compiling query array: - $queryParts = array( + $queryParts = [ 'SELECT' => $fieldList, 'FROM' => $table . $leftjoin, 'WHERE' => $this->pidSelect . ' AND ' . $table . '.pid > 0' . @@ -713,10 +744,10 @@ public function makeQueryArray($table, $id, $addWhere = "", $fieldList = '') BackendUtility::versioningPlaceholderClause($table) . ' ' . $addWhere . ' ' . ($search ? ' AND ' . $search : '') . $catWhere, - 'GROUPBY' => '',//$table.'.uid', + 'GROUPBY' => '', //$table.'.uid', 'ORDERBY' => Database::getInstance()->stripOrderBy($orderBy), - 'LIMIT' => $limit - ); + 'LIMIT' => $limit, + ]; if (!$this->isAdmin && ($this->selectedCategories || !$this->lTSprop['noListWithoutCatSelection']) && $this->showOnlyEditable) { $queryParts = $this->ckeckDisallowedCategories($queryParts); @@ -730,16 +761,16 @@ public function makeQueryArray($table, $id, $addWhere = "", $fieldList = '') * @param $queryParts * * @return mixed - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ protected function ckeckDisallowedCategories($queryParts) { - if (count($this->excludeCats) || count($this->includeCats)) { + if ((is_countable($this->excludeCats) ? count($this->excludeCats) : 0) || (is_countable($this->includeCats) ? count($this->includeCats) : 0)) { // if showOnlyEditable is set, we check for each found record if it has any disallowed category assigned $tmpLimit = $queryParts['LIMIT']; unset($queryParts['LIMIT']); $res = Database::getInstance()->exec_SELECT_queryArray($queryParts); - $results = array(); + $results = []; while (($row = Database::getInstance()->sql_fetch_assoc($res))) { $results[$row['uid']] = $row['uid']; @@ -774,27 +805,21 @@ protected function ckeckDisallowedCategories($queryParts) * @param $uid * * @return array - * @throws \Doctrine\DBAL\DBALException + * @throws DBALException */ protected function getCategories($uid) { $res = Database::getInstance()->exec_SELECTquery( 'tt_news_cat.uid', 'tt_news_cat LEFT JOIN tt_news_cat_mm AS mm ON tt_news_cat.uid=mm.uid_foreign', - 'tt_news_cat.deleted=0 AND mm.uid_local=' . $uid); + 'tt_news_cat.deleted=0 AND mm.uid_local=' . $uid + ); - $categories = array(); + $categories = []; while (($row = Database::getInstance()->sql_fetch_assoc($res))) { $categories[] = $row['uid']; } return $categories; } - - } - - - - - diff --git a/Classes/Module/PageLayoutView.php b/Classes/Module/PageLayoutView.php index 3160ae8..63a73d1 100644 --- a/Classes/Module/PageLayoutView.php +++ b/Classes/Module/PageLayoutView.php @@ -14,17 +14,19 @@ * * The TYPO3 project - inspiring people to share! */ - use Doctrine\DBAL\Driver\Statement; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; +use TYPO3\CMS\Backend\Clipboard\Clipboard; use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider; use TYPO3\CMS\Backend\Controller\Page\LocalizationController; use TYPO3\CMS\Backend\Controller\PageLayoutController; +use TYPO3\CMS\Backend\Routing\PreviewUriBuilder; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Tree\View\PageTreeView; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; @@ -32,10 +34,12 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Database\ReferenceIndex; +use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Page\PageRenderer; @@ -150,7 +154,7 @@ class PageLayoutView implements LoggerAwareInterface 'sys_language_uid' => 0, // Which language 'cols' => '1,0,2,3', - 'activeCols' => '1,0,2,3' + 'activeCols' => '1,0,2,3', // Which columns can be accessed by current BE user ]; @@ -167,7 +171,7 @@ class PageLayoutView implements LoggerAwareInterface public $tt_contentData = [ 'nextThree' => [], 'prev' => [], - 'next' => [] + 'next' => [], ]; /** @@ -551,7 +555,7 @@ class PageLayoutView implements LoggerAwareInterface public $addElement_tdCssClass = []; /** - * @var \TYPO3\CMS\Backend\Clipboard\Clipboard + * @var Clipboard */ protected $clipboard; @@ -670,15 +674,11 @@ public function getTable($table, $id, $fields = '') if (isset($this->externalTables[$table])) { return $this->getExternalTables($id, $table); } - // Branch out based on table name: - switch ($table) { - case 'pages': - return $this->getTable_pages($id); - case 'tt_content': - return $this->getTable_tt_content($id); - default: - return ''; - } + return match ($table) { + 'pages' => $this->getTable_pages($id), + 'tt_content' => $this->getTable_tt_content($id), + default => '', + }; } /** @@ -748,7 +748,7 @@ public function getTable_pages($id) // Items $this->eCounter = $this->firstElementNumber; // Creating elements: - list($flag, $code) = $this->fwd_rwd_nav(); + [$flag, $code] = $this->fwd_rwd_nav(); $out .= $code; $editUids = []; if ($flag) { @@ -784,11 +784,11 @@ public function getTable_pages($id) $urlParameters = [ 'edit' => [ 'pages' => [ - $editIdList => 'edit' - ] + $editIdList => 'edit', + ], ], 'columnsOnly' => $field, - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); @@ -808,8 +808,8 @@ public function getTable_pages($id) $theData[$field] = ''; break; default: - if (strpos($field, 'table_') === 0) { - $f2 = substr($field, 6); + if (str_starts_with((string)$field, 'table_')) { + $f2 = substr((string)$field, 6); if ($GLOBALS['TCA'][$f2]) { $theData[$field] = ' ' . ' -

' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '

+

' . htmlspecialchars((string)$this->tt_contentConfig['languageCols'][$lP]) . '

' . ($languageMode !== '' ? '' . $languageMode . '' : '') . ' '; // "View page" icon is added: $viewLink = ''; if (!VersionState::cast($this->getPageLayoutController()->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) { - $onClick = BackendUtility::viewOnClick( - $this->id, - '', - BackendUtility::BEgetRootLine($this->id), - '', - '', - '&L=' . $lP - ); - $viewLink = '' . $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . ''; + $onClick = PreviewUriBuilder::create($this->id, '')->withSection('')->withAdditionalQueryParameters('&L=' . $lP)->buildDispatcherDataAttributes(); + $viewLink = '' . $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . ''; } // Language overlay page header: if ($lP) { @@ -1321,30 +1314,30 @@ public function getTable_tt_content($id) $urlParameters = [ 'edit' => [ 'pages' => [ - $pageLocalizationRecord['uid'] => 'edit' - ] + $pageLocalizationRecord['uid'] => 'edit', + ], ], // Disallow manual adjustment of the language field for pages 'overrideVals' => [ 'pages' => [ - 'sys_language_uid' => $lP - ] + 'sys_language_uid' => $lP, + ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); $editLink = ( - $this->getBackendUser()->check('tables_modify', 'pages') - ? '' - . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '' - : '' + $this->getBackendUser()->check('tables_modify', 'pages') + ? '' + . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '' + : '' ); $defaultLanguageElements = []; array_walk($defaultLanguageElementsByColumn, function (array $columnContent) use (&$defaultLanguageElements) { - $defaultLanguageElements = array_merge($defaultLanguageElements, $columnContent); + $defaultLanguageElements = [...$defaultLanguageElements, ...$columnContent]; }); $localizationButtons = []; @@ -1359,7 +1352,7 @@ public function getTable_tt_content($id) . $editLink . (!empty($localizationButtons) ? implode(LF, $localizationButtons) : '') . '' - . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageLocalizationRecord['title'], 20)) + . ' ' . $recordIcon . ' ' . htmlspecialchars((string)GeneralUtility::fixed_lgd_cs($pageLocalizationRecord['title'], 20)) ; } else { $editLink = ''; @@ -1373,19 +1366,19 @@ public function getTable_tt_content($id) $urlParameters = [ 'edit' => [ 'pages' => [ - $this->id => 'edit' - ] + $this->id => 'edit', + ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); $editLink = ( - $this->getBackendUser()->check('tables_modify', 'pages') - ? '' - . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '' - : '' + $this->getBackendUser()->check('tables_modify', 'pages') + ? '' + . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '' + : '' ); } @@ -1394,7 +1387,7 @@ public function getTable_tt_content($id) . $viewLink . $editLink . '' - . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20)); + . ' ' . $recordIcon . ' ' . htmlspecialchars((string)GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20)); } $sCont[$lP] = ' ' . $lPLabel . ''; @@ -1498,10 +1491,10 @@ public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = $urlParameters = [ 'edit' => [ $table => [ - $this->id => 'new' - ] + $this->id => 'new', + ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); @@ -1517,7 +1510,7 @@ public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = while ($row = $result->fetch()) { BackendUtility::workspaceOL($table, $row); if (is_array($row)) { - list($flag, $code) = $this->fwd_rwd_nav(); + [$flag, $code] = $this->fwd_rwd_nav(); $out .= $code; if ($flag) { $Nrow = []; @@ -1532,10 +1525,10 @@ public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = $urlParameters = [ 'edit' => [ $table => [ - $row['uid'] => 'edit' - ] + $row['uid'] => 'edit', + ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); @@ -1592,7 +1585,7 @@ public function dataFields($fieldArr, $table, $row, $out = []) $out[$fieldName] = $this->thumbCode($row, $table, $fieldName); } else { // ... otherwise just render the output: - $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs( + $out[$fieldName] = nl2br(htmlspecialchars(trim((string)GeneralUtility::fixed_lgd_cs( BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']), 250 )))); @@ -1600,16 +1593,16 @@ public function dataFields($fieldArr, $table, $row, $out = []) } else { // Each field is separated by
and shown in the same cell (If not a TCA field, then explode // the field name with ";" and check each value there as a TCA configured field) - $theFields = explode(';', $fieldName); + $theFields = explode(';', (string)$fieldName); // Traverse fields, separated by ";" (displayed in a single cell). foreach ($theFields as $fName2) { if ($GLOBALS['TCA'][$table]['columns'][$fName2]) { $out[$fieldName] .= '' . htmlspecialchars($this->getLanguageService()->sL( - $GLOBALS['TCA'][$table]['columns'][$fName2]['label'] - )) . '' . '  ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs( - BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']), - 25 - )) . '
'; + $GLOBALS['TCA'][$table]['columns'][$fName2]['label'] + )) . '' . '  ' . htmlspecialchars((string)GeneralUtility::fixed_lgd_cs( + BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']), + 25 + )) . '
'; } } } @@ -1638,7 +1631,7 @@ public function headerFields($fieldArr, $table, $out = []) { foreach ($fieldArr as $fieldName) { $ll = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'])); - $out[$fieldName] = $ll ? $ll : ' '; + $out[$fieldName] = $ll ?: ' '; } return $out; } @@ -1661,7 +1654,7 @@ protected function getContentRecordsPerColumn($table, $id, array $columns, $addi 'tt_content', $id, [ - $additionalWhereClause + $additionalWhereClause, ] ); @@ -1774,7 +1767,7 @@ public function pages_drawItem($row, $fieldArr) switch ($field) { case 'title': $showPageId = !empty($userTsConfig['options.']['pageTree.']['showPageIdWithTitle']); - $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20)); + $pTitle = htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field], 20)); $theData[$field] = $row['treeIcons'] . $theIcon . ($showPageId ? '[' . $row['uid'] . '] ' : '') . $pTitle; break; case 'php_tree_stop': @@ -1787,17 +1780,17 @@ public function pages_drawItem($row, $fieldArr) $urlParameters = [ 'edit' => [ 'pages' => [ - $row['uid'] => 'edit' - ] + $row['uid'] => 'edit', + ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); - $onClick = BackendUtility::viewOnClick($row['uid'], '', BackendUtility::BEgetRootLine($row['uid'])); + $onClick = PreviewUriBuilder::create($row['uid'])->buildDispatcherDataAttributes(); $eI = - '' . $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() . ''; @@ -1813,16 +1806,16 @@ public function pages_drawItem($row, $fieldArr) break; case 'shortcut': case 'shortcut_mode': - if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) { + if ((int)$row['doktype'] === PageRepository::DOKTYPE_SHORTCUT) { $theData[$field] = $this->getPagesTableFieldValue($field, $row); } break; default: - if (strpos($field, 'table_') === 0) { - $f2 = substr($field, 6); + if (str_starts_with((string)$field, 'table_')) { + $f2 = substr((string)$field, 6); if ($GLOBALS['TCA'][$f2]) { $c = $this->numberOfRecords($f2, $row['uid']); - $theData[$field] = ($c ? $c : ''); + $theData[$field] = ($c ?: ''); } } else { $theData[$field] = $this->getPagesTableFieldValue($field, $row); @@ -1843,7 +1836,7 @@ public function pages_drawItem($row, $fieldArr) */ protected function getPagesTableFieldValue($field, array $row) { - return htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field])); + return htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field])); } /********************************** @@ -1866,7 +1859,7 @@ public function tt_content_drawColHeader($colName, $editParams = '') // Edit whole of column: if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT) && $this->getBackendUser()->checkLanguageAccess(0)) { $iconsArr['edit'] = '' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . ''; } @@ -1924,14 +1917,14 @@ protected function tt_content_drawFooter(array $row) // Content element annotation if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']) && !empty($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']])) { - $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]); + $info[] = htmlspecialchars((string)$row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]); } // Call drawFooter hooks foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) { - throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, 1404378171); + throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, 1_404_378_171); } $hookObject->preProcess($this, $info, $row); } @@ -1971,8 +1964,8 @@ public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButton $urlParameters = [ 'edit' => [ 'tt_content' => [ - $this->tt_contentData['nextThree'][$row['uid']] => 'edit' - ] + $this->tt_contentData['nextThree'][$row['uid']] => 'edit', + ], ], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'], ]; @@ -1997,33 +1990,33 @@ public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButton $value = 1; $label = 'hide'; } - $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']) + $params = '&data[tt_content][' . ($row['_ORIG_uid'] ?: $row['uid']) . '][' . $hiddenField . ']=' . $value; - $out .= '' . $this->iconFactory->getIcon('actions-edit-' . strtolower($label), Icon::SIZE_SMALL)->render() . ''; } // Delete $disableDelete = (bool)\trim( - $backendUser->getTSConfig()['options.']['disableDelete.']['tt_content'] + (string)($backendUser->getTSConfig()['options.']['disableDelete.']['tt_content'] ?? $backendUser->getTSConfig()['options.']['disableDelete'] - ?? '0' + ?? '0') ); if (!$disableDelete) { $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1'; $refCountMsg = BackendUtility::referenceCount( - 'tt_content', - $row['uid'], - ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'), - $this->getReferenceCount('tt_content', $row['uid']) - ) . BackendUtility::translationCount( - 'tt_content', - $row['uid'], - ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord') - ); + 'tt_content', + $row['uid'], + ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'), + $this->getReferenceCount('tt_content', $row['uid']) + ) . BackendUtility::translationCount( + 'tt_content', + $row['uid'], + ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord') + ); $confirm = $this->getLanguageService()->getLL('deleteWarning') . $refCountMsg; - $out .= 'tt_contentData['prev'][$row['uid']]) { $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']]; $moveButtonContent .= '' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . ''; if (!$dragDropEnabled) { @@ -2056,7 +2049,7 @@ public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButton if ($this->tt_contentData['next'][$row['uid']]) { $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']]; $moveButtonContent .= '' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . ''; if (!$dragDropEnabled) { @@ -2079,7 +2072,7 @@ public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButton } // Get record locking status: if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) { - $additionalIcons[] = '' + $additionalIcons[] = '' . $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . ''; } // Call stats information hook @@ -2101,8 +2094,6 @@ public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButton * Gets the number of records referencing the record with the UID $uid in * the table $tableName. * - * @param string $tableName - * @param int $uid * @return int The number of references to record $uid in table */ protected function getReferenceCount(string $tableName, int $uid): int @@ -2118,7 +2109,6 @@ protected function getReferenceCount(string $tableName, int $uid): int /** * Determine whether Drag & Drop should be allowed * - * @param array $row * @return bool */ protected function isDragAndDropAllowed(array $row) @@ -2167,7 +2157,7 @@ public function tt_content_drawItem($row) foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) { - throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawItemHookInterface::class, 1218547409); + throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawItemHookInterface::class, 1_218_547_409); } $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row); } @@ -2234,7 +2224,7 @@ public function tt_content_drawItem($row) break; case 'menu': $contentType = $this->CType_labels[$row['CType']]; - $out .= $this->linkEditContent('' . htmlspecialchars($contentType) . '', $row) . '
'; + $out .= $this->linkEditContent('' . htmlspecialchars((string)$contentType) . '', $row) . '
'; // Add Menu Type $menuTypeLabel = $this->getLanguageService()->sL( BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type']) @@ -2249,7 +2239,7 @@ public function tt_content_drawItem($row) case 'shortcut': if (!empty($row['records'])) { $shortcutContent = []; - $recordList = explode(',', $row['records']); + $recordList = explode(',', (string)$row['records']); foreach ($recordList as $recordIdentifier) { $split = BackendUtility::splitTable_Uid($recordIdentifier); $tableName = empty($split[0]) ? 'tt_content' : $split[0]; @@ -2262,7 +2252,7 @@ public function tt_content_drawItem($row) $shortcutRecord['uid'] ); $shortcutContent[] = $icon - . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord)); + . htmlspecialchars((string)BackendUtility::getRecordTitle($tableName, $shortcutRecord)); } } $out .= implode('
', $shortcutContent) . '
'; @@ -2292,8 +2282,8 @@ public function tt_content_drawItem($row) $out .= '' . $this->getLanguageService()->getLL('noPluginSelected') . ''; } $out .= htmlspecialchars($this->getLanguageService()->sL( - BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']) - )) . '
'; + BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']) + )) . '
'; break; default: $contentType = $this->CType_labels[$row['CType']]; @@ -2302,7 +2292,7 @@ public function tt_content_drawItem($row) } if ($contentType) { - $out .= $this->linkEditContent('' . htmlspecialchars($contentType) . '', $row) . '
'; + $out .= $this->linkEditContent('' . htmlspecialchars((string)$contentType) . '', $row) . '
'; if ($row['bodytext']) { $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '
'; } @@ -2341,15 +2331,15 @@ protected function generateListForCTypeMenu(array $row) $table = 'pages'; $field = 'pages'; // get categories instead of pages - if (strpos($row['menu_type'], 'categorized_') !== false) { + if (str_contains((string)$row['menu_type'], 'categorized_')) { $table = 'sys_category'; $field = 'selected_categories'; } - if (trim($row[$field]) === '') { + if (trim((string)$row[$field]) === '') { return ''; } $content = ''; - $uidList = explode(',', $row[$field]); + $uidList = explode(',', (string)$row[$field]); foreach ($uidList as $uid) { $uid = (int)$uid; $record = BackendUtility::getRecord($table, $uid, 'title'); @@ -2458,7 +2448,7 @@ public function newLanguageButton($defaultLanguageUids, $lP) . ' data-table="tt_content"' . ' data-page-id="' . (int)GeneralUtility::_GP('id') . '"' . ' data-language-id="' . $lP . '"' - . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '"' + . ' data-language-name="' . htmlspecialchars((string)$this->tt_contentConfig['languageCols'][$lP]) . '"' . '>' . $this->iconFactory->getIcon('actions-localize', Icon::SIZE_SMALL)->render() . ' ' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate')) @@ -2488,12 +2478,12 @@ public function newContentElementOnClick($id, $colPos, $sys_language) 'colPos' => $colPos, 'sys_language_uid' => $sys_language, 'uid_pid' => $id, - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]); $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue((string)$url) . ';'; } else { - $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]=' - . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language); + $onClick = GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit') . ('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]=' + . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language) . '&returnUrl=' . rawurlencode((string)GeneralUtility::getIndpEnv('REQUEST_URI')); } return $onClick; } @@ -2513,10 +2503,10 @@ public function linkEditContent($str, $row) $urlParameters = [ 'edit' => [ 'tt_content' => [ - $row['uid'] => 'edit' - ] + $row['uid'] => 'edit', + ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'] + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'], ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); @@ -2577,7 +2567,7 @@ public function languageSelector($id) // which, when finished editing should return back to the current page (returnUrl) $parameters = [ 'justLocalized' => 'pages:' . $id . ':' . $languageUid, - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters); @@ -2586,7 +2576,7 @@ public function languageSelector($id) $redirectUrl ); - $output .= ''; + $output .= ''; } return '
' @@ -2637,7 +2627,7 @@ public function getResult(Statement $result, string $table = 'tt_content'): arra protected function initializeClipboard() { // Start clipboard - $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class); + $this->clipboard = GeneralUtility::makeInstance(Clipboard::class); // Initialize - reads the clipboard content from the user session $this->clipboard->initializeClipboard(); @@ -2654,8 +2644,6 @@ protected function initializeClipboard() /** * Generates the data for previous and next elements which is needed for movements. - * - * @param array $rowArray */ protected function generateTtContentDataArray(array $rowArray) { @@ -2727,7 +2715,7 @@ public function renderText($input) { $input = strip_tags($input); $input = GeneralUtility::fixed_lgd_cs($input, 1500); - return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', false)); + return nl2br(htmlspecialchars(trim((string)$input), ENT_QUOTES, 'UTF-8', false)); } /** @@ -2767,8 +2755,8 @@ public function getProcessedValue($table, $fieldList, array $row, array &$info) // Traverse fields from $fieldList foreach ($fieldArr as $field) { if ($row[$field]) { - $info[] = '' . htmlspecialchars($this->itemLabels[$field]) . ' ' - . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field])); + $info[] = '' . htmlspecialchars((string)$this->itemLabels[$field]) . ' ' + . htmlspecialchars((string)BackendUtility::getProcessedValue($table, $field, $row[$field])); } } } @@ -2784,8 +2772,8 @@ public function isDisabled($table, $row) { $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']; return $enableCols['disabled'] && $row[$enableCols['disabled']] - || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME'] - || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME']; + || $enableCols['starttime'] && $row[$enableCols['starttime']] > GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp') + || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'); } /** @@ -2823,7 +2811,7 @@ public function getTableMenu($id) $theTables = ['tt_content']; // External tables: if (is_array($this->externalTables)) { - $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables))); + $theTables = array_unique([...$theTables, ...array_keys($this->externalTables)]); } $out = ''; // Traverse tables to check: @@ -2833,7 +2821,7 @@ public function getTableMenu($id) && ( isset($this->externalTables[$tName]) || $tName === 'fe_users' || $tName === 'tt_content' - || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName) + || ExtensionManagementUtility::isLoaded($tName) ) ) { // Make query to count records from page: @@ -2895,8 +2883,6 @@ public function getThumbCodeUnlinked($row, $table, $field) * Checks whether translated Content Elements exist in the desired language * If so, deny creating new ones via the UI * - * @param array $contentElements - * @param int $language * @return bool */ protected function checkIfTranslationsExistInLanguage(array $contentElements, int $language) @@ -2938,7 +2924,7 @@ protected function checkIfTranslationsExistInLanguage(array $contentElements, in FlashMessage::class, sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $siteLanguage->getTitle()), sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), $siteLanguage->getTitle()), - FlashMessage::WARNING + AbstractMessage::WARNING ); $service = GeneralUtility::makeInstance(FlashMessageService::class); $queue = $service->getMessageQueueByIdentifier(); @@ -3185,7 +3171,7 @@ public function getSearchBox($formFields = true) '', - '' + '', ]; } // Make level selector: @@ -3207,12 +3193,12 @@ public function getSearchBox($formFields = true) foreach ($searchLevelItems as $kv => $label) { $opt[] = ''; + (string)$label + ) . ''; } $lMenu = ''; + $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.search_levels') + ) . '" id="search_levels">' . implode('', $opt) . ''; // Table with the search box: $content = ''; - $markerArray['###BROWSE_LINKS###'] = $sTables; + $markerArray['###BROWSE_LINKS###'] = $sTables; - return $markerArray; + return $markerArray; } /* @@ -159,19 +163,19 @@ function user_substPageBrowser($markerArray, $conf) { plugin.tt_news.userPageBrowserFunc = user_substPageBrowser2 plugin.tt_news { - # Pagebrowser settings - pageBrowser { - maxPages = 10 - # set this to '0' if you want the pagebrowser to display only numbers - showPBrowserText = 0 - actPage_stdWrap.wrap = | - page_stdWrap.wrap = - } - # Example for overriding values from locallang.php with other values - _LOCAL_LANG.default { - pi_list_browseresults_prev = previous - pi_list_browseresults_next = next - } + # Pagebrowser settings + pageBrowser { + maxPages = 10 + # set this to '0' if you want the pagebrowser to display only numbers + showPBrowserText = 0 + actPage_stdWrap.wrap = | + page_stdWrap.wrap = + } + # Example for overriding values from locallang.php with other values + _LOCAL_LANG.default { + pi_list_browseresults_prev = previous + pi_list_browseresults_next = next + } } */ @@ -183,65 +187,63 @@ function user_substPageBrowser($markerArray, $conf) { * @param array $conf : * @return array marker Array with filled in markers for the pagebrowser */ -function user_substPageBrowser2 ($markerArray, $conf) { - $pObj = &$conf['parentObj']; // make a reference to the parent object - - $newsCount = $pObj->internal['res_count'] ; - $begin_at = $pObj->piVars['pointer'] * $pObj->config['limit']; - // Make Next link - if ($newsCount > $begin_at + $pObj->config['limit']) { - $next = ($begin_at + $pObj->config['limit'] > $newsCount) ? $newsCount - $pObj->config['limit']:$begin_at + $pObj->config['limit']; - $next = intval($next / $pObj->config['limit']); - $markerArray['###LINK_NEXT###'] = $pObj->pi_linkTP_keepPIvars($pObj->pi_getLL('pi_list_browseresults_next', 'Next >'), array('pointer' => $next), $pObj->allowCaching); - } else { - $markerArray['###LINK_NEXT###'] = ''; - } - // Make Previous link - if ($begin_at) { - $prev = ($begin_at - $pObj->config['limit'] < 0)?0:$begin_at - $pObj->config['limit']; - $prev = intval($prev / $pObj->config['limit']); - $markerArray['###LINK_PREV###'] = $pObj->pi_linkTP_keepPIvars($pObj->pi_getLL('pi_list_browseresults_prev', '< Previous'), array('pointer' => $prev), $pObj->allowCaching) . ' '; - } else { - $markerArray['###LINK_PREV###'] = ''; - } - - $firstPage = 0; - $lastPage = $pages = ceil($newsCount / $pObj->config['limit']); - $actualPage = floor($begin_at / $pObj->config['limit']); - - if ($lastPage > $pObj->conf['pageBrowser.']['maxPages']) { - // if there are more pages than allowed in 'maxPages', calculate the first and the lastpage to show. The current page is shown in the middle of the list. - $precedingPagesCount = floor($pObj->conf['pageBrowser.']['maxPages'] / 2); - $followPagesCount = $pObj->conf['pageBrowser.']['maxPages'] - $precedingPagesCount; - // set firstpage and lastpage - $firstPage = $actualPage - $precedingPagesCount; - if ($firstPage < 0) { - $firstPage = 0; - $lastPage = $pObj->conf['pageBrowser.']['maxPages']; - } else { - $lastPage = $actualPage + $followPagesCount; - if ($lastPage > $pages) { - $lastPage = $pages; - $firstPage = $pages - $pObj->conf['pageBrowser.']['maxPages']; - } - } - } - - for ($i = $firstPage ; $i < $lastPage; $i++) { - if (($begin_at >= $i * $pObj->config['limit']) && ($begin_at < $i * $pObj->config['limit'] + $pObj->config['limit'])) { - $item = ($pObj->conf['pageBrowser.']['showPBrowserText']?$pObj->pi_getLL('pi_list_browseresults_page', 'Page'):'') . (string)($i + 1); - $markerArray['###BROWSE_LINKS###'] .= ' ' . $pObj->local_cObj->stdWrap($item, $pObj->conf['pageBrowser.']['actPage_stdWrap.']) . ' '; - } else { - $item = ($pObj->conf['pageBrowser.']['showPBrowserText']?$pObj->pi_getLL('pi_list_browseresults_page', 'Page'):'') . (string)($i + 1); - - $markerArray['###BROWSE_LINKS###'] .= $pObj->pi_linkTP_keepPIvars($pObj->local_cObj->stdWrap($item, $pObj->conf['pageBrowser.']['page_stdWrap.']) . ' ', array('pointer' => $i), $pObj->allowCaching) . ' '; - } - } - - - $markerArray['###BROWSE_LINKS###'] = $markerArray['###LINK_PREV###'] . $markerArray['###BROWSE_LINKS###'] . $markerArray['###LINK_NEXT###']; - - return $markerArray; +function user_substPageBrowser2($markerArray, $conf) +{ + $pObj = &$conf['parentObj']; // make a reference to the parent object + + $newsCount = $pObj->internal['res_count']; + $begin_at = $pObj->piVars['pointer'] * $pObj->config['limit']; + // Make Next link + if ($newsCount > $begin_at + $pObj->config['limit']) { + $next = ($begin_at + $pObj->config['limit'] > $newsCount) ? $newsCount - $pObj->config['limit'] : $begin_at + $pObj->config['limit']; + $next = (int)($next / $pObj->config['limit']); + $markerArray['###LINK_NEXT###'] = $pObj->pi_linkTP_keepPIvars($pObj->pi_getLL('pi_list_browseresults_next', 'Next >'), ['pointer' => $next], $pObj->allowCaching); + } else { + $markerArray['###LINK_NEXT###'] = ''; + } + // Make Previous link + if ($begin_at) { + $prev = ($begin_at - $pObj->config['limit'] < 0) ? 0 : $begin_at - $pObj->config['limit']; + $prev = (int)($prev / $pObj->config['limit']); + $markerArray['###LINK_PREV###'] = $pObj->pi_linkTP_keepPIvars($pObj->pi_getLL('pi_list_browseresults_prev', '< Previous'), ['pointer' => $prev], $pObj->allowCaching) . ' '; + } else { + $markerArray['###LINK_PREV###'] = ''; + } + + $firstPage = 0; + $lastPage = $pages = ceil($newsCount / $pObj->config['limit']); + $actualPage = floor($begin_at / $pObj->config['limit']); + + if ($lastPage > $pObj->conf['pageBrowser.']['maxPages']) { + // if there are more pages than allowed in 'maxPages', calculate the first and the lastpage to show. The current page is shown in the middle of the list. + $precedingPagesCount = floor($pObj->conf['pageBrowser.']['maxPages'] / 2); + $followPagesCount = $pObj->conf['pageBrowser.']['maxPages'] - $precedingPagesCount; + // set firstpage and lastpage + $firstPage = $actualPage - $precedingPagesCount; + if ($firstPage < 0) { + $firstPage = 0; + $lastPage = $pObj->conf['pageBrowser.']['maxPages']; + } else { + $lastPage = $actualPage + $followPagesCount; + if ($lastPage > $pages) { + $lastPage = $pages; + $firstPage = $pages - $pObj->conf['pageBrowser.']['maxPages']; + } + } + } + + for ($i = $firstPage; $i < $lastPage; $i++) { + if (($begin_at >= $i * $pObj->config['limit']) && ($begin_at < $i * $pObj->config['limit'] + $pObj->config['limit'])) { + $item = ($pObj->conf['pageBrowser.']['showPBrowserText'] ? $pObj->pi_getLL('pi_list_browseresults_page', 'Page') : '') . (string)($i + 1); + $markerArray['###BROWSE_LINKS###'] .= ' ' . $pObj->local_cObj->stdWrap($item, $pObj->conf['pageBrowser.']['actPage_stdWrap.']) . ' '; + } else { + $item = ($pObj->conf['pageBrowser.']['showPBrowserText'] ? $pObj->pi_getLL('pi_list_browseresults_page', 'Page') : '') . (string)($i + 1); + + $markerArray['###BROWSE_LINKS###'] .= $pObj->pi_linkTP_keepPIvars($pObj->local_cObj->stdWrap($item, $pObj->conf['pageBrowser.']['page_stdWrap.']) . ' ', ['pointer' => $i], $pObj->allowCaching) . ' '; + } + } + + $markerArray['###BROWSE_LINKS###'] = $markerArray['###LINK_PREV###'] . $markerArray['###BROWSE_LINKS###'] . $markerArray['###LINK_NEXT###']; + + return $markerArray; } - - diff --git a/Resources/Examples/PHP/news_amenuUserFunc2.php b/Resources/Examples/PHP/news_amenuUserFunc2.php index 6d58a6d..e088324 100755 --- a/Resources/Examples/PHP/news_amenuUserFunc2.php +++ b/Resources/Examples/PHP/news_amenuUserFunc2.php @@ -40,10 +40,10 @@ /* add this to your TS setup: - # include the php script - includeLibs.newsAmenuUserFunc = EXT:tt_news/res/example_amenuUserFunc.php - # call user function - plugin.tt_news.newsAmenuUserFunc = user_processAmenu + # include the php script + includeLibs.newsAmenuUserFunc = EXT:tt_news/res/example_amenuUserFunc.php + # call user function + plugin.tt_news.newsAmenuUserFunc = user_processAmenu */ @@ -54,41 +54,39 @@ * @param [type] $conf: ... * @return array the processed Array */ -function user_processAmenu($amenuItemsArr, $conf){ - $lConf = $conf['parentObj']->conf; // get the config array from parent object - #debug($lConf); - #debug ($amenuItemsArr); - // initialize template markers - $markerArray['###ARCHIVE_YEAR###']=''; +function user_processAmenu($amenuItemsArr, $conf) +{ + $markerArray = []; + $lConf = $conf['parentObj']->conf; // get the config array from parent object + //debug($lConf); + //debug ($amenuItemsArr); + // initialize template markers + $markerArray['###ARCHIVE_YEAR###'] = ''; - // template-part for the old template - #$tmpl = '###ARCHIVE_YEAR###'; + // template-part for the old template + //$tmpl = '###ARCHIVE_YEAR###'; - // template-part for the new css based template: - $tmpl = '
  • ###ARCHIVE_YEAR###
  • '; + // template-part for the new css based template: + $tmpl = '
  • ###ARCHIVE_YEAR###
  • '; - $oldyear = 0; - $out = array(); - if ($amenuItemsArr) { - foreach ($amenuItemsArr as $item){ - $year = date('Y',$item['data']['start']); // set year + $oldyear = 0; + $out = []; + if ($amenuItemsArr) { + foreach ($amenuItemsArr as $item) { + $year = date('Y', $item['data']['start']); // set year - if ($year != $oldyear) { // if year has changed, add a new item to the array - if ($item['data']['start']<20000) { - $year = 'no date'; - } - $markerArray['###ARCHIVE_YEAR###'] = $conf['parentObj']->local_cObj->stdWrap($year, $lConf['wrap3.']); - $out[]['html'] = $conf['parentObj']->cObj->substituteMarkerArrayCached($tmpl, $markerArray); - - $oldyear = $year; - } - $out[] = $item; - } - } - #debug ($out); - return $out; + if ($year != $oldyear) { // if year has changed, add a new item to the array + if ($item['data']['start'] < 20000) { + $year = 'no date'; + } + $markerArray['###ARCHIVE_YEAR###'] = $conf['parentObj']->local_cObj->stdWrap($year, $lConf['wrap3.']); + $out[]['html'] = $conf['parentObj']->cObj->substituteMarkerArrayCached($tmpl, $markerArray); + $oldyear = $year; + } + $out[] = $item; + } + } + //debug ($out); + return $out; } - - - diff --git a/Resources/Examples/PHP/tt_news_languageMenu.php b/Resources/Examples/PHP/tt_news_languageMenu.php index 14f1914..8e73b2e 100755 --- a/Resources/Examples/PHP/tt_news_languageMenu.php +++ b/Resources/Examples/PHP/tt_news_languageMenu.php @@ -1,4 +1,10 @@ */ - /** * language menu that keeps the links vars from tt_news * * @param [type] $content: ... - * @return void - * @access public */ -function user_languageMenu($content) { - // image files for deafultlanguage - $defaultflag = array( - 'on' => '', - 'off' => '', - ) ; - - - // image files for additional languages. the numbers are the uids of the system languages - $flagimages = array( - '1' => array( - 'on' => '', - 'off' => '' - ), - '2' => array( - 'on' => '', - 'off' => '' - ) - ); - // Pointer for the active language - $pointer = ''; +function user_languageMenu($content) +{ + $paramArray = []; + // image files for deafultlanguage + $defaultflag = ['on' => '', 'off' => '']; + // image files for additional languages. the numbers are the uids of the system languages + $flagimages = ['1' => ['on' => '', 'off' => ''], '2' => ['on' => '', 'off' => '']]; + // Pointer for the active language + $pointer = ''; + // First, select all pages_language_overlay records on the current page. Each represents a possibility for a language. + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages_language_overlay', 'pid=' . (int)($GLOBALS['TSFE']->id) . $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'), 'sys_language_uid'); + $langArr = []; + while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { + $langArr[$row['sys_language_uid']] = $row['title']; + } - // First, select all pages_language_overlay records on the current page. Each represents a possibility for a language. - $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages_language_overlay', 'pid=' . intval($GLOBALS['TSFE']->id) . $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'), 'sys_language_uid'); + $queryString = explode('&', (string)GeneralUtility::implodeArrayForUrl('', $GLOBALS['_GET'])); + if ($queryString) { + foreach ($queryString as $val) { + $tmp = explode('=', (string)$val); + $paramArray[$tmp[0]] = $val; + } + $excludeList = 'id,L,tx_ttnews[pointer]'; + foreach ($paramArray as $key => $val) { + if (!$val || ($excludeList && GeneralUtility::inList($excludeList, $key))) { + unset($paramArray[$key]); + } + } + $tmpParams = implode('&', $paramArray); - $langArr = array(); - while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { - $langArr[$row['sys_language_uid']] = $row['title']; - } + $newsAddParams = $tmpParams ? '&' . $tmpParams : ''; + } + // unset the global linkVar "L" for the language menu because it's build new in this script + $relevantParametersForCachingFromPageArguments = []; + $pageArguments = $GLOBALS['REQUEST']->getAttribute('routing'); + $queryParams = $pageArguments->getDynamicArguments(); + if (!empty($queryParams) && ($pageArguments->getArguments()['cHash'] ?? false)) { + $queryParams['id'] = $pageArguments->getPageId(); + $relevantParametersForCachingFromPageArguments = GeneralUtility::makeInstance(CacheHashCalculator::class)->getRelevantParameters(HttpUtility::buildQueryString($queryParams)); + } + $linkVarsBak = $relevantParametersForCachingFromPageArguments; + $tmplinkVars = GeneralUtility::trimExplode('&', $GLOBALS['TSFE']->linkVars); + if ($tmplinkVars) { + foreach ($tmplinkVars as $kl => $vl) { + if (!$vl || preg_match('/L=[0-9]/', (string)$vl)) { + unset($tmplinkVars[$kl]); + } + } + $GLOBALS['TSFE']->linkVars = implode('&', $tmplinkVars); + } - $queryString = explode('&', \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $GLOBALS['_GET'])) ; - if ($queryString) { - while (list(, $val) = each($queryString)) { - $tmp = explode('=', $val); - $paramArray[$tmp[0]] = $val; - } - $excludeList = 'id,L,tx_ttnews[pointer]'; - while (list($key, $val) = each($paramArray)) { - if (!$val || ($excludeList && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($excludeList, $key))) { - unset($paramArray[$key]); - } - } - $tmpParams = implode('&', $paramArray); + $tmpLang = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id'); - $newsAddParams = $tmpParams?'&' . $tmpParams:''; - } - // unset the global linkVar "L" for the language menu because it's build new in this script - $linkVarsBak = $GLOBALS['TSFE']->linkVars; - $tmplinkVars = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('&', $GLOBALS['TSFE']->linkVars) ; - if ($tmplinkVars) { - while (list($kl, $vl) = each($tmplinkVars)) { - if (!$vl || preg_match('/L=[0-9]/', $vl)) { - unset($tmplinkVars[$kl]); - } - } - $GLOBALS['TSFE']->linkVars = implode('&', $tmplinkVars) ; - } + $flags = []; + // flag for the default language + if ($GLOBALS['TSFE']->page['l18n_cfg'] == 1) { // = "Hide default Translation" is activated + $flags[0] = $defaultflag['off']; + } else { + $flags[0] = ($tmpLang == 0 ? $pointer : '') . $GLOBALS['TSFE']->cObj->typolink($defaultflag['on'], ['parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams) ? $newsAddParams . '&L=0' : $newsAddParams)]); + } - $tmpLang = $GLOBALS['TSFE']->sys_language_uid; - - $flags = array(); - // flag for the default language - if ($GLOBALS['TSFE']->page['l18n_cfg']==1){ // = "Hide default Translation" is activated - $flags[0] = $defaultflag['off']; - } else { - $flags[0] = ($tmpLang == 0?$pointer:'') . $GLOBALS['TSFE']->cObj->typolink($defaultflag['on'], array('parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=0':$newsAddParams))); - } - - // flags for the additional language - if (is_array($flagimages)) { - foreach ($flagimages as $fk => $fv) { - if ($langArr[$fk]) { - $flags[$fk] = ($tmpLang == $fk?$pointer:'') . $GLOBALS['TSFE']->cObj->typolink($fv['on'], array('parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=' . $fk:$newsAddParams))); - } else { - $flags[$fk] = $fv['off']; - } - } - } - $content = '

    ' - . implode('', $flags) . '

    '; - // restore link vars - $GLOBALS['TSFE']->linkVars = $linkVarsBak; - return $content; + // flags for the additional language + if (is_array($flagimages)) { + foreach ($flagimages as $fk => $fv) { + if ($langArr[$fk]) { + $flags[$fk] = ($tmpLang == $fk ? $pointer : '') . $GLOBALS['TSFE']->cObj->typolink($fv['on'], ['parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams) ? $newsAddParams . '&L=' . $fk : $newsAddParams)]); + } else { + $flags[$fk] = $fv['off']; + } + } + } + $content = '

    ' + . implode('', $flags) . '

    '; + // restore link vars + $GLOBALS['TSFE']->linkVars = $linkVarsBak; + return $content; } - - diff --git a/Resources/Public/Images/Icons/Resources/Public/Icons/Extension.gif b/Resources/Public/Images/Icons/Resources/Public/Icons/Extension.gif new file mode 100644 index 0000000..d289c1e Binary files /dev/null and b/Resources/Public/Images/Icons/Resources/Public/Icons/Extension.gif differ diff --git a/composer.json b/composer.json index f316223..09bc072 100644 --- a/composer.json +++ b/composer.json @@ -1,39 +1,61 @@ { - "name": "rupertgermann/tt_news", - "type": "typo3-cms-extension", - "description": "Website news with front page teasers and article handling inside.", - "homepage": "https://typo3.org/extensions/repository/view/tt_news", - "keywords": [ - "TYPO3", - "news", - "extension" - ], - "version": "11.0.0", - "license": "GPL-2.0-or-later", - "authors": [ - { - "name": "Rupert Germann", - "email": "rg@pick2.de", - "homepage": "https://pick2-webservices.de", - "role": "Lead" + "name": "rupertgermann/tt_news", + "type": "typo3-cms-extension", + "description": "Website news with front page teasers and article handling inside.", + "homepage": "https://typo3.org/extensions/repository/view/tt_news", + "keywords": [ + "TYPO3", + "news", + "extension" + ], + "version": "11.0.0", + "license": "GPL-2.0-or-later", + "authors": [ + { + "name": "Rupert Germann", + "email": "rg@pick2.de", + "homepage": "https://pick2-webservices.de", + "role": "Lead" + }, + { + "name": "Jakob Berlin", + "email": "jakob@ybals.de", + "role": "Member" + } + ], + "require": { + "typo3/cms-core": ">=10.4.0 <12.0.0" }, - { - "name": "Jakob Berlin", - "email": "jakob@ybals.de", - "role": "Member" - } - ], - "require": { - "typo3/cms-core": ">=10.4.0 <12.0.0" - }, - "autoload": { - "psr-4": { - "RG\\TtNews\\": "Classes/" - } - }, - "extra": { - "typo3/cms": { - "extension-key": "tt_news" + "autoload": { + "psr-4": { + "RG\\TtNews\\": "Classes/" + } + }, + "extra": { + "typo3/cms": { + "extension-key": "tt_news", + "app-dir": ".Build", + "web-dir": ".Build/Web" + } + }, + "require-dev": { + "ssch/typo3-rector": "^1.6", + "typo3/coding-standards": "^0.7", + "typo3/minimal": "^11.5" + }, + "config": { + "vendor-dir": ".Build/vendor", + "bin-dir": ".Build/bin", + "allow-plugins": { + "typo3/cms-composer-installers": true, + "typo3/class-alias-loader": true + } + }, + "scripts": { + "phpcsfixer": ".Build/bin/php-cs-fixer fix --config=Build/php-cs-fixer.php", + "rector": [ + ".Build/bin/rector process --config Build/rector.php", + "@phpcsfixer" + ] } - } } diff --git a/ext_conf_template.txt b/ext_conf_template.txt index 9612361..53da668 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,33 +1,30 @@ - # cat=basic/enable/100; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.requireCategories +# cat=basic/enable/100; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.requireCategories requireCategories = 0 - # cat=basic/enable/170; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.showBackEndModule +# cat=basic/enable/170; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.showBackEndModule showBackEndModule = 0 - # cat=basic//20; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.prependAtCopy +# cat=basic//20; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.prependAtCopy prependAtCopy = 1 - # cat=basic//30; type=options[title,short,author]; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label +# cat=basic//30; type=options[title,short,author]; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label label = title - # cat=basic//40; type=options[,datetime,title,short,author,tstamp,category]; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label_alt -label_alt = +# cat=basic//40; type=options[,datetime,title,short,author,tstamp,category]; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label_alt +label_alt = - # cat=basic//45; type=options[,datetime,title,short,author,tstamp,category]; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label_alt2 -label_alt2 = +# cat=basic//45; type=options[,datetime,title,short,author,tstamp,category]; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label_alt2 +label_alt2 = - # cat=basic//50; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label_alt_force +# cat=basic//50; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.label_alt_force label_alt_force = 0 - # cat=basic/language/130; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.l10n_mode_prefixLangTitle +# cat=basic/language/130; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.l10n_mode_prefixLangTitle l10n_mode_prefixLangTitle = 1 - # cat=basic/language/140; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.l10n_mode_imageExclude +# cat=basic/language/140; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.l10n_mode_imageExclude l10n_mode_imageExclude = 1 - # cat=basic/language/150; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.hideNewLocalizations +# cat=basic/language/150; type=boolean; label=LLL:EXT:tt_news/Resources/Private/Language/locallang.xml:extmng.hideNewLocalizations hideNewLocalizations = 0 - - - diff --git a/ext_emconf.php b/ext_emconf.php index b4bcc70..1e83f12 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -5,10 +5,7 @@ 'description' => 'Website news with front page teasers and article handling inside.', 'category' => 'plugin', 'version' => '11.0.0', - 'module' => 'mod1', 'state' => 'beta', - 'modify_tables' => 'be_groups,be_users', - 'clearcacheonload' => 0, 'author' => 'Rupert Germann [pick2webServices]', 'author_email' => 'rg@pick2.de', 'author_company' => 'www.pick2.de', diff --git a/ext_localconf.php b/ext_localconf.php index d848e86..0e758ad 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,5 +1,20 @@ main_news + userFunc = ' . TtNews::class . '->main_news # validate some configuration values and display a message if errors have been found enableConfigValidation = 1 @@ -27,7 +42,7 @@ '); // add default rendering for pi_layout plugin - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript( + ExtensionManagementUtility::addTypoScript( 'tt_news', 'setup', 'tt_content.list.20.9 =< plugin.tt_news', @@ -35,27 +50,26 @@ ); if (TYPO3_MODE === 'BE') { // Apply PageTSconfig - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig( + ExtensionManagementUtility::addPageTSConfig( '' ); - // Page module hook - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['9']['tt_news'] = \RG\TtNews\Hooks\PageModuleHook::class . '->getExtensionSummary'; + // Page module hook + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['9']['tt_news'] = PageModuleHook::class . '->getExtensionSummary'; } if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tt_news_cache'] ?? null)) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tt_news_cache'] = [ - 'backend' => TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, - 'frontend' => TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class + 'backend' => Typo3DatabaseBackend::class, + 'frontend' => VariableFrontend::class, ]; } // register news cache table for "clear all caches" $GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearAllCache_additionalTables']['tt_news_cache'] = 'tt_news_cache'; - // in order to make "direct Preview links" for tt_news work again in TYPO3 >= 6, unset pageNotFoundOnCHashError if a BE_USER is logged in - $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']); + $configuredCookieName = trim((string)$GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']); if (empty($configuredCookieName)) { $configuredCookieName = 'be_typo_user'; } @@ -63,20 +77,19 @@ $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError'] = 0; } - $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][\RG\TtNews\Form\FormDataProvider::class] = [ + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][FormDataProvider::class] = [ 'depends' => [ - \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew::class, - ] + DatabaseRowInitializeNew::class, + ], ]; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['migrateImagesToFal'] = \RG\TtNews\Update\migrateImagesToFal::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['migrateCatImagesToFal'] = \RG\TtNews\Update\migrateCatImagesToFal::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['migrateFileAttachmentsToFal'] = \RG\TtNews\Update\migrateFileAttachmentsToFal::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tt_news_populateslugs'] = \RG\TtNews\Update\PopulateNewsSlugs::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['migrateImagesToFal'] = migrateImagesToFal::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['migrateCatImagesToFal'] = migrateCatImagesToFal::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['migrateFileAttachmentsToFal'] = migrateFileAttachmentsToFal::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tt_news_populateslugs'] = PopulateNewsSlugs::class; // add a dummy ValueMapper for the archive Aspect to get rid of the cHash in archive links - $GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['ArchiveValueMapper'] = RG\TtNews\Routing\Aspect\ArchiveValueMapper::class; - + $GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['ArchiveValueMapper'] = ArchiveValueMapper::class; }; $boot(); diff --git a/ext_tables.php b/ext_tables.php index f701155..bc974f8 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,42 +1,53 @@ getMajorVersion() < 11) { - if ($confArr['showBackEndModule']) { - TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( + ExtensionManagementUtility::addModule( 'web', 'txttnewsM1', '', null, [ - 'routeTarget' => RG\TtNews\Module\NewsAdminModule::class . '::mainAction', + 'routeTarget' => NewsAdminModule::class . '::mainAction', 'access' => 'user,group', 'name' => 'web_txttnewsM1', 'navigationComponentId' => 'typo3-pagetree', @@ -50,71 +61,50 @@ ); // Register HTML template for the tt_news BackEnd Module - $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_ttnews_admin.html'] = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('tt_news') . 'mod1/mod_ttnews_admin.html'; + $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_ttnews_admin.html'] = ExtensionManagementUtility::extPath('tt_news') . 'mod1/mod_ttnews_admin.html'; } } - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tt_news'][0]['fList'] = 'uid,title,author,category,datetime,archivedate,tstamp'; $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tt_news'][0]['icon'] = true; // Register context menu for the tt_news category manager - $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'][] = array( - 'name' => \RG\TtNews\Menu\ClickMenu::class - ); + $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'][] = ['name' => ClickMenu::class]; - /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); + /** @var IconRegistry $iconRegistry */ + $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); $iconRegistry->registerIcon( 'apps-pagetree-folder-contains-news', - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - array( - 'source' => 'EXT:tt_news/Resources/Public/Images/Icons/ext_icon_ttnews_folder.gif', - ) + BitmapIconProvider::class, + ['source' => 'EXT:tt_news/Resources/Public/Images/Icons/ext_icon_ttnews_folder.gif'] ); $iconRegistry->registerIcon( 'ttnews-content-element-wizard-icon', - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - array( - 'source' => 'EXT:tt_news/Resources/Public/Images/ContentElementWizardIcon.gif', - ) + BitmapIconProvider::class, + ['source' => 'EXT:tt_news/Resources/Public/Images/ContentElementWizardIcon.gif'] ); $iconRegistry->registerIcon( 'tt-news', - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - array( - 'source' => 'EXT:tt_news/Resources/Public/Images/Icons/ext_icon.gif', - ) + BitmapIconProvider::class, + ['source' => 'EXT:tt_news/Resources/Public/Images/Icons/ext_icon.gif'] ); $iconRegistry->registerIcon( 'tt-news-article', - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - array( - 'source' => 'EXT:tt_news/Resources/Public/Images/Icons/tt_news_article.gif', - ) + BitmapIconProvider::class, + ['source' => 'EXT:tt_news/Resources/Public/Images/Icons/tt_news_article.gif'] ); $iconRegistry->registerIcon( 'tt-news-exturl', - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - array( - 'source' => 'EXT:tt_news/Resources/Public/Images/Icons/tt_news_exturl.gif', - ) + BitmapIconProvider::class, + ['source' => 'EXT:tt_news/Resources/Public/Images/Icons/tt_news_exturl.gif'] ); // add folder icon $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['contains-tt_news'] = 'apps-pagetree-folder-contains-news'; - $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = array( - 0 => 'LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xlf:tt_news', - 1 => 'tt_news', - 2 => 'apps-pagetree-folder-contains-news' - ); - - + $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [0 => 'LLL:EXT:tt_news/Resources/Private/Language/locallang_tca.xlf:tt_news', 1 => 'tt_news', 2 => 'apps-pagetree-folder-contains-news']; } - }; $boot(); unset($boot); - diff --git a/ext_tables.sql b/ext_tables.sql index e7b0f3d..7b7114a 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -83,6 +83,8 @@ CREATE TABLE tt_news_cat ( parent_category int(11) unsigned DEFAULT '0' NOT NULL, description text, + l10n_state text, + PRIMARY KEY (uid), KEY parent (pid), KEY parent_category (parent_category)