first commit

This commit is contained in:
salam committed 2026-10-19 08:18:39 +02:00
commit 1218dd1517
12716 files changed
+989233

No files matched your search

@@ -0,0 +1,144 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Adminpanel\Service\ConfigurationService;
use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Abstract base class for Admin Panel Modules containing helper methods and default interface implementations
* Extend this class when writing own admin panel modules (or implement the Interface directly)
*/
abstract class AbstractModule implements ModuleInterface, ConfigurableInterface, SubmoduleProviderInterface
{
/**
* @var ModuleInterface[]
*/
protected $subModules = [];
/**
* Main Configuration (from UserTSConfig, admPanel)
*
* @var array
*/
protected $mainConfiguration;
/**
* @var ConfigurationService
*/
protected $configurationService;
public function __construct()
{
$this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$this->mainConfiguration = $this->configurationService->getMainConfiguration();
}
/**
* Returns true if the module is
* -> either enabled via TSConfig admPanel.enable
* -> or any setting is overridden
* override is a way to use functionality of the admin panel without displaying the admin panel to users
* for example: hidden records or pages can be displayed by default
*
* @return bool
*/
public function isEnabled(): bool
{
$identifier = $this->getIdentifier();
$result = $this->isEnabledViaTsConfig();
if ($this->mainConfiguration['override.'][$identifier] ?? false) {
$result = (bool)$this->mainConfiguration['override.'][$identifier];
}
return $result;
}
/**
* @inheritdoc
*/
public function setSubModules(array $subModules): void
{
$this->subModules = $subModules;
}
/**
* @inheritdoc
*/
public function getSubModules(): array
{
return $this->subModules;
}
/**
* @inheritdoc
*/
public function hasSubmoduleSettings(): bool
{
$hasSettings = false;
foreach ($this->subModules as $subModule) {
if ($subModule instanceof ModuleSettingsProviderInterface) {
$hasSettings = true;
break;
}
if ($subModule instanceof SubmoduleProviderInterface) {
$hasSettings = $subModule->hasSubmoduleSettings();
}
}
return $hasSettings;
}
/**
* Returns the current BE user.
*
* @return BackendUserAuthentication|FrontendBackendUserAuthentication
*/
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
/**
* Returns true if TSConfig admPanel.enable is set for this module (or all modules)
*
* @return bool
*/
protected function isEnabledViaTsConfig(): bool
{
$result = false;
$identifier = $this->getIdentifier();
if (!empty($this->mainConfiguration['enable.']['all'])) {
$result = true;
} elseif (!empty($this->mainConfiguration['enable.'][$identifier])) {
$result = true;
}
return $result;
}
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
/**
* Abstract SubModule - Base class for sub modules in the admin panel
*
* Extend this class when writing own sub modules
*/
abstract class AbstractSubModule implements ModuleInterface, ContentProviderInterface
{
/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
@@ -0,0 +1,39 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* AdminPanel ConfigurableInterface
*
* Used to indicate that an adminpanel module can be enabled or disabled via configuration
*
* Usual implementation is done via user tsconfig
* @see \TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule::isEnabled()
*/
interface ConfigurableInterface
{
/**
* Module is enabled
* -> should be initialized
* A module may be enabled but not shown
* -> only the initializeModule() method
* will be called
*
* @return bool
*/
public function isEnabled(): bool;
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel interface to denote that a module has content to be rendered
*
* In general there are two main types of admin panel modules: those providing settings influencing page rendering
* (for example the preview module provides settings for displaying hidden pages or records) and those rendering
* information regarding the current request (for example the log module).
*
* Modules implementing this interface denote that they render module content.
*/
interface ContentProviderInterface
{
/**
* Main method for content generation of an admin panel module.
* Return content as HTML. For modules implementing the DataProviderInterface
* the "ModuleData" object is automatically filled with the stored data - if
* no data is given a "fresh" ModuleData object is injected.
*
* @param \TYPO3\CMS\Adminpanel\ModuleApi\ModuleData $data
* @return string
*/
public function getContent(ModuleData $data): string;
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ServerRequestInterface;
/**
* Adminpanel interface to denote that a module provides data to be stored for the current request
*
* Adminpanel modules can save data to the adminpanel request cache and access this data in the rendering process.
* Data necessary for rendering the module content has to be returned via this interface implementation, as this allows
* for separate data collection and rendering and is a pre-requisite for a standalone debug tool.
*/
interface DataProviderInterface
{
/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @return \TYPO3\CMS\Adminpanel\ModuleApi\ModuleData
*/
public function getDataToStore(ServerRequestInterface $request): ModuleData;
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ServerRequestInterface;
/**
* Adminpanel interface to denote that a module has tasks to perform on initialization of the request
*
* Modules that need to set data / options early in the rendering process to be able to collect data, should implement
* this interface - for example the log module uses the initialization to register the admin panel log collection early
* in the rendering process.
*
* Initialize is called in the PSR-15 middleware stack through admin panel initialisation via the AdminPanel MainController.
*
* @see \TYPO3\CMS\Adminpanel\Middleware\AdminPanelInitiator::process()
* @see \TYPO3\CMS\Adminpanel\Controller\MainController::initialize()
*/
interface InitializableInterface
{
/**
* Initialize the module - runs early in a TYPO3 request
*
* @param ServerRequestInterface $request
*/
public function initializeModule(ServerRequestInterface $request): void;
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/**
* ModuleData is a simple wrapper object which extends ArrayObject
* which is used to hold Adminpanel module data
*
* It's a separate class to add semantic meaning to its' usage
*/
class ModuleData extends \ArrayObject
{
}
@@ -0,0 +1,39 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* ModuleDataStorageCollection is an object storage for adminpanel modules and their data
*/
class ModuleDataStorageCollection extends \SplObjectStorage
{
public function addModuleData(DataProviderInterface $module, ModuleData $moduleData): void
{
$this->attach($module, $moduleData);
}
public function getHash($object)
{
if ($object instanceof ModuleInterface) {
return $object->getIdentifier();
}
throw new \InvalidArgumentException(
'Only modules implementing ' . ModuleInterface::class . ' are allowed to be stored',
1535301628
);
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel interface for all modules
*
* Every adminpanel module needs to implement this interface as a bare minimum.
*/
interface ModuleInterface
{
/**
* Identifier for this module,
* for example "preview" or "cache"
*
* @return string
*/
public function getIdentifier(): string;
/**
* Module label
*
* @return string
*/
public function getLabel(): string;
}
@@ -0,0 +1,38 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel module settings interface denotes that a module has own settings.
*
* The adminpanel knows two types of settings:
* - ModuleSettings are relevant for the module itself and its representation (for example the log module provides settings
* where displayed log level and grouping of the module can be configured)
* - PageSettings are relevant for rendering the page (for example the preview module provides settings showing or hiding
* hidden content elements or simulating a specific rendering time)
*
* If a module provides settings relevant to its own content, use this interface.
*
* @see \TYPO3\CMS\Adminpanel\ModuleApi\PageSettingsProviderInterface
*/
interface ModuleSettingsProviderInterface
{
/**
* @return string
*/
public function getSettings(): string;
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ServerRequestInterface;
/**
* Adminpanel interface for modules that need to react on changed configuration
* (for example if fluid debug settings change, the frontend cache should be cleared)
*/
interface OnSubmitActorInterface
{
/**
* Executed on saving / submit of the configuration form
* Can be used to react to changed settings
* (for example: clearing a specific cache)
*
* @param array $configurationToSave
* @param ServerRequestInterface $request
*/
public function onSubmit(array $configurationToSave, ServerRequestInterface $request): void;
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel page settings interface denotes that a module has settings regarding the page rendering.
* The adminpanel knows two types of settings:
* - ModuleSettings are relevant for the module itself and its representation (for example the log module provides settings
* where displayed log level and grouping of the module can be configured)
* - PageSettings are relevant for rendering the page (for example the preview module provides settings showing or hiding
* hidden content elements or simulating a specific rendering time)
* If a module provides settings changing the rendering of the main page request, use this interface.
*
* @see \TYPO3\CMS\Adminpanel\ModuleApi\ModuleSettingsProviderInterface
*/
interface PageSettingsProviderInterface
{
/**
* @return string
*/
public function getPageSettings(): string;
}
@@ -0,0 +1,44 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel interface to denote that a module has own resource files.
*
* An adminpanel module implementing this interface may deliver custom JavaScript and Css files to provide additional
* styling and JavaScript functionality
*/
interface ResourceProviderInterface
{
/**
* Returns a string array with javascript files that will be rendered after the module
*
* Example: return ['EXT:adminpanel/Resources/Public/JavaScript/Modules/Edit.js'];
*
* @return array
*/
public function getJavaScriptFiles(): array;
/**
* Returns a string array with css files that will be rendered after the module
*
* Example: return ['EXT:adminpanel/Resources/Public/JavaScript/Modules/Edit.css'];
*
* @return array
*/
public function getCssFiles(): array;
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel shortinfo provider interface can be used to add the module to the short info bar of the adminpanel
*
* Modules providing shortinfo will be displayed in the bottom bar of the adminpanel and may provide "at a glance" info
* about the current state (for example the log module provides the number of warnings and errors directly).
*
* Be aware that modules with submodules at the moment can only render one short info (the one of the "parent" module).
* This will likely change in TYPO3 v10.0.
*/
interface ShortInfoProviderInterface
{
/**
* Displayed directly in the bar
*
* @return string
*/
public function getShortInfo(): string;
/**
* Icon identifier - needs to be registered in iconRegistry
*
* @return string
*/
public function getIconIdentifier(): string;
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Adminpanel\ModuleApi;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Adminpanel interface providing hierarchical functionality for modules
*
* A module implementing this interface may have submodules. Be aware that the current implementation of the adminpanel
* renders a maximum level of 2 for modules. If you need to render more levels, write your own module and implement
* multi-hierarchical rendering in the getContent method
*
* @see \TYPO3\CMS\Adminpanel\ModuleApi\ContentProviderInterface::getContent()
*/
interface SubmoduleProviderInterface
{
/**
* Sets array of module instances (instances of `ModuleInterface`) as submodules
*
* @param \TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface[] $subModules
*/
public function setSubModules(array $subModules): void;
/**
* Returns an array of module instances
*
* @return \TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface[]
*/
public function getSubModules(): array;
/**
* Return true if any of the submodules has settings to be rendered
* (can be used to render settings in a central place)
*
* @return bool
*/
public function hasSubmoduleSettings(): bool;
}