[TASK] Move EXT:impexp entrypoint to Routing 27/42727/3
authorBenjamin Mack <benni@typo3.org>
Tue, 18 Aug 2015 18:46:56 +0000 (20:46 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 18 Aug 2015 19:05:34 +0000 (21:05 +0200)
Resolves: #69167
Releases: master
Change-Id: I7e20ed767803621cb555dcf3bc47c269505390ea
Reviewed-on: http://review.typo3.org/42727
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/impexp/Classes/Controller/ImportExportController.php
typo3/sysext/impexp/Configuration/Backend/Routes.php [new file with mode: 0644]
typo3/sysext/impexp/Modules/ImportExport/conf.php [deleted file]
typo3/sysext/impexp/Modules/ImportExport/index.php [deleted file]
typo3/sysext/impexp/ext_tables.php

index 7983685..bba3a33 100644 (file)
@@ -14,8 +14,10 @@ namespace TYPO3\CMS\Impexp\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Http\Response;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Page\PageRenderer;
@@ -29,7 +31,7 @@ use TYPO3\CMS\Lang\LanguageService;
 /**
  * Main script class for the Import / Export facility
  */
-class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
+class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass implements \TYPO3\CMS\Core\Http\ControllerInterface {
 
        /**
         * @var array|\TYPO3\CMS\Core\Resource\File[]
@@ -79,6 +81,13 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
        protected $iconFactory;
 
        /**
+        * The name of the module
+        *
+        * @var string
+        */
+       protected $moduleName = 'xMOD_tximpexp';
+
+       /**
         * Constructor
         */
        public function __construct() {
@@ -89,6 +98,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
         * @return void
         */
        public function init() {
+               $this->MCONF['name'] = $this->moduleName;
                parent::init();
                $this->vC = GeneralUtility::_GP('vC');
                $this->lang = $this->getLanguageService();
@@ -155,12 +165,59 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
         * Print the content
         *
         * @return void
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
         */
        public function printContent() {
+               GeneralUtility::logDeprecatedFunction();
                echo $this->content;
        }
 
        /**
+        * Injects the request object for the current request and gathers all data
+        *
+        * IMPORTING DATA:
+        *
+        * Incoming array has syntax:
+        * GETvar 'id' = import page id (must be readable)
+        *
+        * file =       (pointing to filename relative to PATH_site)
+        *
+        * [all relation fields are clear, but not files]
+        * - page-tree is written first
+        * - then remaining pages (to the root of import)
+        * - then all other records are written either to related included pages or if not found to import-root (should be a sysFolder in most cases)
+        * - then all internal relations are set and non-existing relations removed, relations to static tables preserved.
+        *
+        * EXPORTING DATA:
+        *
+        * Incoming array has syntax:
+        *
+        * file[] = file
+        * dir[] = dir
+        * list[] = table:pid
+        * record[] = table:uid
+        *
+        * pagetree[id] = (single id)
+        * pagetree[levels]=1,2,3, -1 = currently unpacked tree, -2 = only tables on page
+        * pagetree[tables][]=table/_ALL
+        *
+        * external_ref[tables][]=table/_ALL
+        *
+        * @param ServerRequestInterface $request
+        * @return \Psr\Http\Message\ResponseInterface $response
+        */
+       public function processRequest(ServerRequestInterface $request) {
+               $GLOBALS['SOBE'] = $this;
+               $this->init();
+               $this->main();
+
+               /** @var Response $response */
+               $response = GeneralUtility::makeInstance(Response::class);
+               $response->getBody()->write($this->content);
+               return $response;
+       }
+
+       /**
         * Create the panel of buttons for submitting the form or otherwise perform operations.
         *
         * @return array all available buttons as an associated array
@@ -171,7 +228,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                        'shortcut' => ''
                );
                if ($this->getBackendUser()->mayMakeShortcut()) {
-                       $buttons['shortcut'] = $this->doc->makeShortcutIcon('tx_impexp', '', $this->MCONF['name']);
+                       $buttons['shortcut'] = $this->doc->makeShortcutIcon('tx_impexp', '', $this->moduleName);
                }
                // Input data grabbed:
                $inData = GeneralUtility::_GP('tx_impexp');
diff --git a/typo3/sysext/impexp/Configuration/Backend/Routes.php b/typo3/sysext/impexp/Configuration/Backend/Routes.php
new file mode 100644 (file)
index 0000000..84c64a9
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Definitions for routes provided by EXT:impexp
+ */
+return [
+       // Register click menu entry point
+       'xMOD_tximpexp' => [
+               'path' => '/record/importexport/',
+               'controller' => \TYPO3\CMS\Impexp\Controller\ImportExportController::class
+       ]
+];
diff --git a/typo3/sysext/impexp/Modules/ImportExport/conf.php b/typo3/sysext/impexp/Modules/ImportExport/conf.php
deleted file mode 100644 (file)
index 1e23e7f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-$MCONF['name'] = 'xMOD_tximpexp';
-$MCONF['script'] = '_DISPATCH';
diff --git a/typo3/sysext/impexp/Modules/ImportExport/index.php b/typo3/sysext/impexp/Modules/ImportExport/index.php
deleted file mode 100644 (file)
index 5663d16..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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!
- */
-
-/**
- * IMPORTING DATA:
- *
- * Incoming array has syntax:
- * GETvar 'id' = import page id (must be readable)
- *
- * file =      (pointing to filename relative to PATH_site)
- *
- *
- *
- * [all relation fields are clear, but not files]
- * - page-tree is written first
- * - then remaining pages (to the root of import)
- * - then all other records are written either to related included pages or if not found to import-root (should be a sysFolder in most cases)
- * - then all internal relations are set and non-existing relations removed, relations to static tables preserved.
- *
- * EXPORTING DATA:
- *
- * Incoming array has syntax:
- *
- * file[] = file
- * dir[] = dir
- * list[] = table:pid
- * record[] = table:uid
- *
- * pagetree[id] = (single id)
- * pagetree[levels]=1,2,3, -1 = currently unpacked tree, -2 = only tables on page
- * pagetree[tables][]=table/_ALL
- *
- * external_ref[tables][]=table/_ALL
- */
-
-$GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\Controller\ImportExportController::class);
-$GLOBALS['SOBE']->init();
-$GLOBALS['SOBE']->main();
-$GLOBALS['SOBE']->printContent();
index e7a9f0a..cfab526 100644 (file)
@@ -3,7 +3,7 @@ defined('TYPO3_MODE') or die();
 
 if (TYPO3_MODE === 'BE') {
        $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'][] = array(
-               'name' => \TYPO3\CMS\Impexp\Clickmenu::class,
+               'name' => \TYPO3\CMS\Impexp\Clickmenu::class
        );
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']['impexp']['TYPO3\\CMS\\Impexp\\Task\\ImportExportTask'] = array(
                'title' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_csh.xlf:.alttitle',
@@ -34,7 +34,7 @@ if (TYPO3_MODE === 'BE') {
                }
        ';
        // Context menu user default configuration
-       $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] .= '
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('
                options.contextMenu.table {
                        virtual_root.items {
                                ' . $importExportActions . '
@@ -48,6 +48,5 @@ if (TYPO3_MODE === 'BE') {
                                ' . $importExportActions . '
                        }
                }
-       ';
-       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath('xMOD_tximpexp', 'EXT:impexp/Modules/ImportExport/');
+       ');
 }