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 = '';
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 '