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,108 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Frontend\Http;
/*
* 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\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\DateTimeAspect;
use TYPO3\CMS\Core\Context\UserAspect;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Context\WorkspaceAspect;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Http\AbstractApplication;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Entry point for the TYPO3 Frontend
*/
class Application extends AbstractApplication
{
/**
* @var string
*/
protected $requestHandler = RequestHandler::class;
/**
* @var string
*/
protected $middlewareStack = 'frontend';
/**
* @var ConfigurationManager
*/
protected $configurationManager;
/**
* @param ConfigurationManager $configurationManager
*/
public function __construct(ConfigurationManager $configurationManager)
{
$this->configurationManager = $configurationManager;
}
/**
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
protected function handle(ServerRequestInterface $request): ResponseInterface
{
if (!$this->checkIfEssentialConfigurationExists()) {
return $this->installToolRedirect();
}
$this->initializeContext();
return parent::handle($request);
}
/**
* Check if LocalConfiguration.php and PackageStates.php exist
*
* @return bool TRUE when the essential configuration is available, otherwise FALSE
*/
protected function checkIfEssentialConfigurationExists(): bool
{
return file_exists($this->configurationManager->getLocalConfigurationFileLocation())
&& file_exists(Environment::getLegacyConfigPath() . '/PackageStates.php');
}
/**
* Create a PSR-7 Response that redirects to the install tool
*
* @return ResponseInterface
*/
protected function installToolRedirect(): ResponseInterface
{
$path = TYPO3_mainDir . 'install.php';
return new RedirectResponse($path, 302);
}
/**
* Initializes the Context used for accessing data and finding out the current state of the application
* Will be moved to a DI-like concept once introduced, for now, this is a singleton
*/
protected function initializeContext()
{
GeneralUtility::makeInstance(Context::class, [
'date' => new DateTimeAspect(new \DateTimeImmutable('@' . $GLOBALS['EXEC_TIME'])),
'visibility' => new VisibilityAspect(),
'workspace' => new WorkspaceAspect(0),
'backend.user' => new UserAspect(null),
'frontend.user' => new UserAspect(null, [0, -1]),
]);
}
}
@@ -0,0 +1,120 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Frontend\Http;
/*
* 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\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface as PsrRequestHandlerInterface;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Http\Dispatcher;
use TYPO3\CMS\Core\Http\NullResponse;
use TYPO3\CMS\Core\Http\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Middleware\EidHandler as EidMiddleware;
/**
* Lightweight alternative to the regular RequestHandler used when $_GET[eID] is set.
* In the future, logic from the EidUtility will be moved to this class.
*
* @deprecated since TYPO3 v9.2, will be removed in TYPO3 v10.0
*/
class EidRequestHandler implements RequestHandlerInterface, PsrRequestHandlerInterface
{
/**
* Constructor handing over the bootstrap and the original request
*/
public function __construct()
{
trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
}
/**
* Handles a frontend request based on the _GP "eID" variable.
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
return $this->handle($request);
}
/**
* This request handler can handle any frontend request.
*
* @param ServerRequestInterface $request The request to process
* @return bool If the request is not an eID request, TRUE otherwise FALSE
*/
public function canHandleRequest(ServerRequestInterface $request): bool
{
trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
return !empty($request->getQueryParams()['eID']) || !empty($request->getParsedBody()['eID']);
}
/**
* Returns the priority - how eager the handler is to actually handle the
* request.
*
* @return int The priority of the request handler.
*/
public function getPriority(): int
{
trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
return 80;
}
/**
* Dispatches the request to the corresponding eID class or eID script
*
* @param ServerRequestInterface $request
* @return ResponseInterface
* @throws Exception
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
// Remove any output produced until now
ob_clean();
/** @var Response $response */
$response = GeneralUtility::makeInstance(Response::class);
$eID = $request->getParsedBody()['eID'] ?? $request->getQueryParams()['eID'] ?? '';
if (empty($eID) || !isset($GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID])) {
return $response->withStatus(404, 'eID not registered');
}
$configuration = $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID];
// Simple check to make sure that it's not an absolute file (to use the fallback)
if (strpos($configuration, '::') !== false || is_callable($configuration)) {
/** @var Dispatcher $dispatcher */
$dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
$request = $request->withAttribute('target', $configuration);
return $dispatcher->dispatch($request, $response);
}
$scriptPath = GeneralUtility::getFileAbsFileName($configuration);
if ($scriptPath === '') {
throw new Exception('Registered eID has invalid script path.', 1416391467);
}
include $scriptPath;
return new NullResponse();
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,46 @@
<?php
namespace TYPO3\CMS\Frontend\Http;
/*
* 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!
*/
/**
* This interface needs to be implemented by all classes that register for the hook in:
* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlHandlers']
*
* It can be used to do custom URL processing during a Frontend request.
* @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10.0 in favor of PSR-15 middlewares.
*/
interface UrlHandlerInterface
{
/**
* Return TRUE if this hook handles the current URL.
* Warning! If TRUE is returned content rendering will be disabled!
* This method will be called in the constructor of the TypoScriptFrontendController
*
* @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::__construct()
* @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::initializeRedirectUrlHandlers()
* @return bool
*/
public function canHandleCurrentUrl();
/**
* Custom processing of the current URL.
*
* If canHandle() has returned TRUE this method needs to take care of redirecting the user or generating custom output.
* This hook will be called BEFORE the user is redirected to an external URL configured in the page properties.
*
* @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::redirectToExternalUrl()
*/
public function handle();
}
@@ -0,0 +1,42 @@
<?php
namespace TYPO3\CMS\Frontend\Http;
/*
* 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!
*/
/**
* This interface needs to be implemented by all classes that register for the hook in:
* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlProcessors']
*
* It can be used manipulate URLs that are generated by the ContentObjectRenderer.
*/
interface UrlProcessorInterface
{
const CONTEXT_COMMON = 'common';
const CONTEXT_FILE = 'file';
const CONTEXT_MAIL = 'mail';
const CONTEXT_EXTERNAL = 'external';
/**
* Generates the JumpURL for the given parameters.
*
* @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::processUrl()
* @param string $context The context in which the URL is generated (e.g. "typolink" or one of the constants above).
* @param string $url The URL that should be processed.
* @param array $configuration The link configuration.
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer The calling content object renderer.
* @param bool $keepProcessing If this is set to FALSE no further hooks will be processed after the current one.
* @return string|null
*/
public function process($context, $url, array $configuration, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer, &$keepProcessing);
}