[TASK] Cleanup wizard initializing 93/21293/8
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 8 Jun 2013 15:51:41 +0000 (17:51 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 20 Jun 2013 18:23:27 +0000 (20:23 +0200)
The patch cleans up the initialization of the various
wizards we have in TYPO3 CMS. Things that are improved:

* Add constructor to all controllers
* Move language inclusion to constructor
* Move init() and sometimes printContent() to the constructor
* Make init() protected
* Add controller to $GLOBALS['SOBE']

Change-Id: I9783e347a3bf983fae8b6bbbbc972ecf56f31f83
Resolves: #48963
Releases: 6.2
Reviewed-on: https://review.typo3.org/21293
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
14 files changed:
typo3/sysext/backend/Classes/Controller/Wizard/AddController.php
typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php
typo3/sysext/backend/Classes/Controller/Wizard/EditController.php
typo3/sysext/backend/Classes/Controller/Wizard/FormsController.php
typo3/sysext/backend/Classes/Controller/Wizard/ListController.php
typo3/sysext/backend/Classes/Controller/Wizard/RteController.php
typo3/sysext/backend/Classes/Controller/Wizard/TableController.php
typo3/wizard_add.php
typo3/wizard_colorpicker.php
typo3/wizard_edit.php
typo3/wizard_forms.php
typo3/wizard_list.php
typo3/wizard_rte.php
typo3/wizard_table.php

index 761b657..f6b632b 100644 (file)
@@ -45,12 +45,6 @@ class AddController {
         */
        public $content;
 
-       // List of files to include.
-       /**
-        * @todo Define visibility
-        */
-       public $include_once = array();
-
        // If set, the TCEmain class is loaded and used to add the returning ID to the parent record.
        /**
         * @todo Define visibility
@@ -90,12 +84,21 @@ class AddController {
        public $returnEditConf;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
+
+               $this->init();
+       }
+
+       /**
         * Initialization of the class.
         *
         * @return void
-        * @todo Define visibility
         */
-       public function init() {
+       protected function init() {
                // Init GPvars:
                $this->P = GeneralUtility::_GP('P');
                $this->returnEditConf = GeneralUtility::_GP('returnEditConf');
@@ -140,7 +143,6 @@ class AddController {
         * Will issue a location-header, redirecting either BACK or to a new alt_doc.php instance...
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                if ($this->returnEditConf) {
index 7b8c05a..c59f6fc 100644 (file)
@@ -116,12 +116,21 @@ class ColorpickerController {
        public $content;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
+
+               $this->init();
+       }
+
+       /**
         * Initialises the Class
         *
         * @return      void
-        * @todo Define visibility
         */
-       public function init() {
+       protected function init() {
                // Setting GET vars (used in frameset script):
                $this->P = GeneralUtility::_GP('P', 1);
                // Setting GET vars (used in colorpicker script):
@@ -191,7 +200,6 @@ class ColorpickerController {
         * Main Method, rendering either colorpicker or frameset depending on ->showPicker
         *
         * @return      void
-        * @todo Define visibility
         */
        public function main() {
                // Show frameset by default:
index 80d8827..af4d1b5 100644 (file)
@@ -51,12 +51,21 @@ class EditController {
        public $doClose;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
+
+               $this->init();
+       }
+
+       /**
         * Initialization of the script
         *
         * @return void
-        * @todo Define visibility
         */
-       public function init() {
+       protected function init() {
                $this->P = GeneralUtility::_GP('P');
                // Used for the return URL to alt_doc.php so that we can close the window.
                $this->doClose = GeneralUtility::_GP('doClose');
@@ -67,7 +76,6 @@ class EditController {
         * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                if ($this->doClose) {
index 733ba0b..0db9745 100644 (file)
@@ -137,12 +137,6 @@ class FormsController {
         */
        public $content;
 
-       // List of files to include.
-       /**
-        * @todo Define visibility
-        */
-       public $include_once = array();
-
        // Used to numerate attachments automatically.
        /**
         * @todo Define visibility
@@ -178,12 +172,21 @@ class FormsController {
        public $special;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
+
+               $this->init();
+       }
+
+       /**
         * Initialization the class
         *
         * @return void
-        * @todo Define visibility
         */
-       public function init() {
+       protected function init() {
                // GPvars:
                $this->P = GeneralUtility::_GP('P');
                $this->special = GeneralUtility::_GP('special');
@@ -208,7 +211,6 @@ class FormsController {
         * Main function for rendering the form wizard HTML
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                if ($this->P['table'] && $this->P['field'] && $this->P['uid']) {
index 58103b1..b9156ac 100644 (file)
@@ -65,11 +65,10 @@ class ListController {
 
        /**
         * Initialization of the class, setting GPvars.
-        *
-        * @return      void
-        * @todo Define visibility
         */
-       public function init() {
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
                $this->P = GeneralUtility::_GP('P');
                $this->table = GeneralUtility::_GP('table');
                $this->id = GeneralUtility::_GP('id');
@@ -80,7 +79,6 @@ class ListController {
         * Will issue a location-header, redirecting either BACK or to a new alt_doc.php instance...
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                // Get this record
index 1ecb57e..e0a1427 100644 (file)
@@ -73,12 +73,21 @@ class RteController {
        public $R_URI;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
+
+               $this->init();
+       }
+
+       /**
         * Initialization of the class
         *
         * @return void
-        * @todo Define visibility
         */
-       public function init() {
+       protected function init() {
                // Setting GPvars:
                $this->P = GeneralUtility::_GP('P');
                $this->popView = GeneralUtility::_GP('popView');
@@ -99,7 +108,6 @@ class RteController {
         * Main function, rendering the document with the iframe with the RTE in.
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                // Translate id to the workspace version:
index 64c3bdb..7ee97c4 100644 (file)
@@ -54,12 +54,6 @@ class TableController {
         */
        public $content;
 
-       // List of files to include.
-       /**
-        * @todo Define visibility
-        */
-       public $include_once = array();
-
        // TRUE, then <input> fields are shown, not textareas.
        /**
         * @todo Define visibility
@@ -115,12 +109,21 @@ class TableController {
        public $tableParsing_delimiter;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $GLOBALS['SOBE'] = $this;
+
+               $this->init();
+       }
+
+       /**
         * Initialization of the class
         *
         * @return void
-        * @todo Define visibility
         */
-       public function init() {
+       protected function init() {
                // GPvars:
                $this->P = GeneralUtility::_GP('P');
                $this->TABLECFG = GeneralUtility::_GP('TABLE');
@@ -149,7 +152,6 @@ class TableController {
         * Main function, rendering the table wizard
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                if ($this->P['table'] && $this->P['field'] && $this->P['uid']) {
index 9f06e67..3dbe0b7 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Wizard to add new records to a group/select TCEform formfield
  *
- * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-$BACK_PATH = '';
 require 'init.php';
-$LANG->includeLLFile('EXT:lang/locallang_wizards.xlf');
-
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\AddController');
-$SOBE->init();
 
-// Include files?
-foreach ($SOBE->include_once as $INC_FILE) {
-       include_once $INC_FILE;
-}
-$SOBE->main();
+$addController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\AddController');
+$addController->main();
 ?>
\ No newline at end of file
index 3072501..8afa8b0 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Colorpicker wizard
  *
- * Revised for TYPO3 3.7 May/2004 by Kasper Skårhøj
- *
  * @author Mathias Schreiber <schreiber@wmdb.de>
  * @author Peter Kühn <peter@kuehn.com>
  * @author Kasper Skårhøj <typo3@typo3.com>
  */
-$GLOBALS['BACK_PATH'] = '';
 require 'init.php';
-$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
 
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\ColorpickerController');
-$SOBE->init();
-$SOBE->main();
-$SOBE->printContent();
+$colorpickerController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\ColorpickerController');
+$colorpickerController->main();
+$colorpickerController->printContent();
 ?>
\ No newline at end of file
index 6d166be..5ea856f 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Wizard to edit records from group/select lists in TCEforms
  *
- * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-$BACK_PATH = '';
 require 'init.php';
-$LANG->includeLLFile('EXT:lang/locallang_wizards.xlf');
 
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\EditController');
-$SOBE->init();
-$SOBE->main();
+$editController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\EditController');
+$editController->main();
 ?>
\ No newline at end of file
index b9c5084..091ee98 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Wizard to help make forms (fx. for tt_content elements) of type 'form'.
  *
- * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
- * XHTML compliant
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-$BACK_PATH = '';
 require 'init.php';
-$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
-
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\FormsController');
-$SOBE->init();
 
-// Include files?
-foreach ($SOBE->include_once as $INC_FILE) {
-       include_once $INC_FILE;
-}
-$SOBE->main();
-$SOBE->printContent();
+$formsController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\FormsController');
+$formsController->main();
+$formsController->printContent();
 ?>
\ No newline at end of file
index 1d48916..57414ab 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Wizard to list records from a page id.
  *
- * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
- * XHTML compliant
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-$BACK_PATH = '';
 require 'init.php';
-$LANG->includeLLFile('EXT:lang/locallang_wizards.xlf');
 
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\ListController');
-$SOBE->init();
-$SOBE->main();
+$listController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\ListController');
+$listController->main();
 ?>
\ No newline at end of file
index 13b8383..c74bbc3 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Wizard to display the RTE in "full screen" mode
  *
- * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
- * XHTML compliant
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-$BACK_PATH = '';
 require 'init.php';
-$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
 \TYPO3\CMS\Backend\Utility\BackendUtility::lockRecords();
 
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\RteController');
-$SOBE->init();
-$SOBE->main();
-$SOBE->printContent();
+$rteController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\RteController');
+$rteController->main();
+$rteController->printContent();
 ?>
\ No newline at end of file
index 89ad062..b2f25ac 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Wizard to help make tables (eg. for tt_content elements) of type "table".
  * Each line is a table row, each cell divided by a |
  *
- * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
- * XHTML compliant
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-$BACK_PATH = '';
 require 'init.php';
-$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
-
-// Make instance:
-$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\TableController');
-$SOBE->init();
 
-// Include files?
-foreach ($SOBE->include_once as $INC_FILE) {
-       include_once $INC_FILE;
-}
-$SOBE->main();
-$SOBE->printContent();
+$tableController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\TableController');
+$tableController->main();
+$tableController->printContent();
 ?>
\ No newline at end of file