Commit 4c8000a4 authored by Benni Mack's avatar Benni Mack Committed by Wouter Wolters
Browse files

[TASK] Migrate tce_db, tce_file and FormEngine entry points to routing

Resolves: #69162
Releases: master
Change-Id: I1cd25425cf344212c192c78bdf4e2f002fb66173
Reviewed-on: http://review.typo3.org/42721


Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent 66954f6e
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Form\DataPreprocessor;
use TYPO3\CMS\Backend\Form\FormEngine;
use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
......@@ -21,6 +22,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Html\HtmlParser;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -38,7 +40,7 @@ use TYPO3\CMS\Frontend\Page\PageRepository;
* Script Class: Drawing the editing form for editing records in TYPO3.
* Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
*/
class EditDocumentController {
class EditDocumentController implements \TYPO3\CMS\Core\Http\ControllerInterface {
/**
* GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg.
......@@ -908,8 +910,10 @@ class EditDocumentController {
* Outputting the accumulated content to screen
*
* @return void
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
public function printContent() {
GeneralUtility::logDeprecatedFunction();
echo $this->content;
}
......@@ -1636,6 +1640,36 @@ class EditDocumentController {
HttpUtility::redirect($retUrl);
}
/**
* Injects the request object for the current request or subrequest
*
* @param ServerRequestInterface $request
* @return \Psr\Http\Message\ResponseInterface $response
*/
public function processRequest(ServerRequestInterface $request) {
BackendUtility::lockRecords();
// Preprocessing, storing data if submitted to
$this->preInit();
// Checks, if a save button has been clicked (or the doSave variable is sent)
if ($this->doProcessData()) {
$formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
if ($formProtection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'editRecord')) {
$this->processData();
}
}
$this->init();
$this->main();
/** @var Response $response */
$response = GeneralUtility::makeInstance(Response::class);
$response->getBody()->write($this->content);
return $response;
}
/**
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
*/
......
......@@ -14,7 +14,9 @@ namespace TYPO3\CMS\Backend\Controller\File;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Resource\Folder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
......@@ -27,7 +29,7 @@ use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility;
* Before TYPO3 4.3, it was located in typo3/tce_file.php and redirected back to a
* $redirectURL. Since 4.3 this class is also used for accessing via AJAX
*/
class FileController {
class FileController implements \TYPO3\CMS\Core\Http\ControllerInterface {
/**
* Array of file-operations.
......@@ -176,6 +178,35 @@ class FileController {
}
}
/**
* Injects the request object for the current request or subrequest
* As this controller goes only through the main() method, it just redirects to the given URL afterwards.
*
* @param ServerRequestInterface $request
* @return \Psr\Http\Message\ResponseInterface $response
*/
public function processRequest(ServerRequestInterface $request) {
$formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
$formToken = isset($request->getQueryParams()['formToken']) ? $request->getQueryParams()['formToken'] : $request->getParsedBody()['formToken'];
if ($formProtection->validateToken($formToken, 'tceAction')) {
$this->main();
}
// Push errors to flash message queue, if there are any
$this->fileProcessor->pushErrorMessagesToFlashMessageQueue();
BackendUtility::setUpdateSignal('updateFolderTree');
/** @var Response $response */
$response = GeneralUtility::makeInstance(Response::class);
if ($this->redirect) {
$response = $response->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect));
return $response->withStatus(303);
} else {
// empty response
return $response;
}
}
/**
* Handles the actual process from within the ajaxExec function
* therefore, it does exactly the same as the real typo3/tce_file.php
......@@ -187,7 +218,6 @@ class FileController {
* @return void
*/
public function processAjaxRequest(array $params, AjaxRequestHandler $ajaxObj) {
$this->init();
$this->main();
$errors = $this->fileProcessor->getErrorMessages();
if (!empty($errors)) {
......
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
......@@ -32,7 +34,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessageService;
* Is not used by FormEngine though (main form rendering script) - that uses the same class (TCEmain) but makes its own initialization (to save the redirect request).
* For all other cases than FormEngine it is recommended to use this script for submitting your editing forms - but the best solution in any case would probably be to link your application to FormEngine, that will give you easy form-rendering as well.
*/
class SimpleDataHandlerController {
class SimpleDataHandlerController implements \TYPO3\CMS\Core\Http\ControllerInterface {
/**
* Array. Accepts options to be set in TCE object. Currently it supports "reverseOrder" (bool).
......@@ -225,8 +227,10 @@ class SimpleDataHandlerController {
* Might also display error messages directly, if any.
*
* @return void
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
public function finish() {
GeneralUtility::logDeprecatedFunction();
// Prints errors, if...
if ($this->prErr) {
$this->tce->printLogErrorMessages($this->redirect);
......@@ -236,6 +240,36 @@ class SimpleDataHandlerController {
}
}
/**
* Injects the request object for the current request or subrequest
* As this controller goes only through the main() method, it just redirects to the given URL afterwards.
*
* @param ServerRequestInterface $request
* @return \Psr\Http\Message\ResponseInterface $response
*/
public function processRequest(ServerRequestInterface $request) {
$formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
$formToken = isset($request->getQueryParams()['formToken']) ? $request->getQueryParams()['formToken'] : $request->getParsedBody()['formToken'];
if ($formProtection->validateToken($formToken, 'tceAction')) {
$this->initClipboard();
$this->main();
}
// Write errors to flash message queue
if ($this->prErr) {
$this->tce->printLogErrorMessages($this->redirect);
}
/** @var Response $response */
$response = GeneralUtility::makeInstance(Response::class);
if ($this->redirect) {
$response = $response->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect));
return $response->withStatus(303);
} else {
// empty response
return $response;
}
}
/**
* Processes all AJAX calls and returns a JSON formatted string
*
......@@ -288,4 +322,4 @@ class SimpleDataHandlerController {
return $GLOBALS['BE_USER'];
}
}
}
\ No newline at end of file
<?php
use TYPO3\CMS\Backend\Controller as Controller;
use TYPO3\CMS\Backend\Controller;
/**
* Definitions for routes provided by EXT:backend
......@@ -33,113 +33,116 @@ return [
'controller' => Controller\LogoutController::class
],
// Register login frameset
'login_frameset' => [
'path' => '/login/frame',
'controller' => Controller\LoginFramesetController::class
],
/** Wizards */
// Register backend_layout wizard
'wizard_backend_layout' => [
'path' => '/wizard/backend_layout',
'controller' => \TYPO3\CMS\Backend\Controller\BackendLayoutWizardController::class
'controller' => Controller\BackendLayoutWizardController::class
],
// Register colorpicker wizard
'wizard_colorpicker' => [
'path' => '/wizard/colorpicker',
'controller' => \TYPO3\CMS\Backend\Controller\Wizard\ColorpickerController::class
'controller' => Controller\Wizard\ColorpickerController::class
],
// Register table wizard
'wizard_table' => [
'path' => '/wizard/table',
'controller' => \TYPO3\CMS\Backend\Controller\Wizard\TableController::class
'controller' => Controller\Wizard\TableController::class
],
// Register rte wizard
'wizard_rte' => [
'path' => '/wizard/rte',
'controller' => \TYPO3\CMS\Backend\Controller\Wizard\RteController::class
'controller' => Controller\Wizard\RteController::class
],
// Register add wizard
'wizard_add' => [
'path' => '/wizard/add',
'controller' => \TYPO3\CMS\Backend\Controller\Wizard\AddController::class
'controller' => Controller\Wizard\AddController::class
],
// Register list wizard
'wizard_list' => [
'path' => '/wizard/list',
'controller' => \TYPO3\CMS\Backend\Controller\Wizard\ListController::class
'controller' => Controller\Wizard\ListController::class
],
// Register edit wizard
'wizard_edit' => [
'path' => '/wizard/edit',
'controller' => \TYPO3\CMS\Backend\Controller\Wizard\EditController::class
'controller' => Controller\Wizard\EditController::class
],
/** File- and folder-related routes */
// Editing the contents of a file
'file_edit' => [
'path' => '/file/editcontent',
'controller' => \TYPO3\CMS\Backend\Controller\File\EditFileController::class
'controller' => Controller\File\EditFileController::class
],
// Create a new folder
'file_newfolder' => [
'path' => '/file/new',
'controller' => \TYPO3\CMS\Backend\Controller\File\CreateFolderController::class
'controller' => Controller\File\CreateFolderController::class
],
// Rename a file
'file_rename' => [
'path' => '/file/rename',
'controller' => \TYPO3\CMS\Backend\Controller\File\RenameFileController::class
'controller' => Controller\File\RenameFileController::class
],
// Replace a file with a different one
'file_replace' => [
'path' => '/file/replace',
'controller' => \TYPO3\CMS\Backend\Controller\File\ReplaceFileController::class
'controller' => Controller\File\ReplaceFileController::class
],
// Upload new files
'file_upload' => [
'path' => '/file/upload',
'controller' => \TYPO3\CMS\Backend\Controller\File\FileUploadController::class
],
// Register login frameset
'login_frameset' => [
'path' => '/login/frame',
'controller' => \TYPO3\CMS\Backend\Controller\LoginFramesetController::class
'controller' => Controller\File\FileUploadController::class
],
/** DB Records-related routes */
// Register record history module
'record_history' => [
'path' => '/record/history',
'controller' => \TYPO3\CMS\Backend\Controller\ContentElement\ElementHistoryController::class
'controller' => Controller\ContentElement\ElementHistoryController::class
],
// Register new record
'db_new' => [
'path' => '/record/new',
'controller' => \TYPO3\CMS\Backend\Controller\NewRecordController::class
'controller' => Controller\NewRecordController::class
],
// Register new content element module
'new_content_element' => [
'path' => '/record/content/new',
'controller' => \TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController::class
'controller' => Controller\ContentElement\NewContentElementController::class
],
// Register move element module
'move_element' => [
'path' => '/record/move',
'controller' => \TYPO3\CMS\Backend\Controller\ContentElement\MoveElementController::class
'controller' => Controller\ContentElement\MoveElementController::class
],
// Register show item module
'show_item' => [
'path' => '/record/info',
'controller' => \TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController::class
'controller' => Controller\ContentElement\ElementInformationController::class
],
// Register browser
......@@ -148,10 +151,43 @@ return [
'controller' => \TYPO3\CMS\Recordlist\Controller\ElementBrowserFramesetController::class
],
// Register dummy window
// Dummy document - displays nothing but background color.
'dummy' => [
'path' => '/empty',
'controller' => \TYPO3\CMS\Backend\Controller\DummyController::class
'controller' => Controller\DummyController::class
],
/** TYPO3 Core Engine-related routes */
/**
* TCE gateway (TYPO3 Core Engine) for database handling
* This script is a gateway for POST forms to \TYPO3\CMS\Core\DataHandling\DataHandler
* that manipulates all information in the database!!
* For syntax and API information, see the document 'TYPO3 Core APIs'
*/
'tce_db' => [
'path' => '/record/commit',
'controller' => Controller\SimpleDataHandlerController::class
],
/**
* Gateway for TCE (TYPO3 Core Engine) file-handling through POST forms.
* This script serves as the fileadministration part of the TYPO3 Core Engine.
* Basically it includes two libraries which are used to manipulate files on the server.
*
* For syntax and API information, see the document 'TYPO3 Core APIs'
*/
'tce_file' => [
'path' => '/file/commit',
'controller' => Controller\File\FileController::class
],
/**
* Main form rendering script
* By sending certain parameters to this script you can bring up a form
* which allows the user to edit the content of one or more database records.
*/
'record_edit' => [
'path' => '/record/edit',
'controller' => Controller\EditDocumentController::class
],
];
<?php
$MCONF['name'] = 'dummy';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
/*
* 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!
*/
/**
* Dummy document - displays nothing but background color.
*/
$dummyController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\DummyController::class);
$dummyController->main();
$dummyController->printContent();
<?php
$MCONF['name'] = 'tce_file';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
/*
* 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!
*/
/**
* Gateway for TCE (TYPO3 Core Engine) file-handling through POST forms.
* This script serves as the fileadministration part of the TYPO3 Core Engine.
* Basically it includes two libraries which are used to manipulate files on the server.
*
* For syntax and API information, see the document 'TYPO3 Core APIs'
*/
$fileController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\File\FileController::class);
$formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'tceAction')) {
$fileController->main();
}
$fileController->finish();
<?php
$MCONF['name'] = 'tce_db';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
/*
* 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!
*/
/**
* TCE gateway (TYPO3 Core Engine) for database handling
* This script is a gateway for POST forms to \TYPO3\CMS\Core\DataHandling\DataHandler
* that manipulates all information in the database!!
* For syntax and API information, see the document 'TYPO3 Core APIs'
*/
$simpleDataHandlerController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\SimpleDataHandlerController::class);
$formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'tceAction')) {
$simpleDataHandlerController->initClipboard();
$simpleDataHandlerController->main();
}
$simpleDataHandlerController->finish();
<?php
$MCONF['name'] = 'record_edit';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
/*
* 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!
*/
/**
* Main form rendering script
* By sending certain parameters to this script you can bring up a form
* which allows the user to edit the content of one or more database records.
*/
\TYPO3\CMS\Backend\Utility\BackendUtility::lockRecords();
/* @var $editDocumentController \TYPO3\CMS\Backend\Controller\EditDocumentController */
$editDocumentController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\EditDocumentController::class);
// Preprocessing, storing data if submitted to
$editDocumentController->preInit();
// Checks, if a save button has been clicked (or the doSave variable is sent)
if ($editDocumentController->doProcessData()) {
$formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'editRecord')) {
$editDocumentController->processData();
}
}
$editDocumentController->init();
$editDocumentController->main();
$editDocumentController->printContent();
......@@ -3,12 +3,6 @@ defined('TYPO3_MODE') or die();
if (TYPO3_MODE === 'BE') {
// Register record edit module
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'record_edit',
'EXT:backend/Modules/FormEngine/'
);
// Register file_navframe
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addCoreNavigationComponent('file', 'file_navframe');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
......@@ -16,18 +10,6 @@ if (TYPO3_MODE === 'BE') {
'EXT:backend/Modules/FileSystemNavigationFrame/'
);
// Register tce_db
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'tce_db',
'EXT:backend/Modules/File/Database/'
);
// Register tce_file
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'tce_file',
'EXT:backend/Modules/File/Administration/'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
'web',
'layout',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment