[CLEANUP] EXT:backend/Classes/Wizard/*.php 52/37652/12
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 8 Mar 2015 21:32:13 +0000 (22:32 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 3 May 2015 10:45:32 +0000 (12:45 +0200)
* declare missing class variable
* remove unused variables
* correct typos
* use === for comparison
* use getters instead of inline makeInstance()
* rename variables

Resolves: #65602
Releases: master
Change-Id: I782c11b4c963ade8b0ede24f18e338b5e9e590b3
Reviewed-on: http://review.typo3.org/37652
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/Wizard/AbstractWizardController.php
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/ListController.php
typo3/sysext/backend/Classes/Controller/Wizard/RteController.php
typo3/sysext/backend/Classes/Controller/Wizard/TableController.php

index 0512b87..a6c71df 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace TYPO3\CMS\Backend\Controller\Wizard;
 
-/**
+/*
  * This file is part of the TYPO3 CMS project.
  *
  * It is free software; you can redistribute it and/or modify it under
@@ -34,22 +34,22 @@ class AbstractWizardController {
         * @return bool
         */
        protected function checkEditAccess($table, $uid) {
-               $calcPermissionRecord = BackendUtility::getRecord($table, $uid);
-               BackendUtility::fixVersioningPid($table, $calcPermissionRecord);
-               if (is_array($calcPermissionRecord)) {
+               $record = BackendUtility::getRecord($table, $uid);
+               BackendUtility::fixVersioningPid($table, $record);
+               if (is_array($record)) {
                        // If pages:
                        if ($table === 'pages') {
-                               $calculatedPermissions = $this->getBackendUserAuthentication()->calcPerms($calcPermissionRecord);
+                               $calculatedPermissions = $this->getBackendUserAuthentication()->calcPerms($record);
                                $hasAccess = $calculatedPermissions & Permission::PAGE_EDIT;
                        } else {
                                // Fetching pid-record first.
                                $calculatedPermissions = $this->getBackendUserAuthentication()->calcPerms(
-                                       BackendUtility::getRecord('pages', $calcPermissionRecord['pid']));
+                                       BackendUtility::getRecord('pages', $record['pid']));
                                $hasAccess = $calculatedPermissions & Permission::CONTENT_EDIT;
                        }
                        // Check internals regarding access:
                        if ($hasAccess) {
-                               $hasAccess = $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $calcPermissionRecord);
+                               $hasAccess = $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $record);
                        }
                } else {
                        $hasAccess = FALSE;
index f25c327..bea7334 100644 (file)
@@ -14,9 +14,13 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Form\DataPreprocessor;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
+use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
 
 /**
  * Script Class for adding new items to a group/select field. Performs proper redirection as needed.
@@ -94,11 +98,11 @@ class AddController extends AbstractWizardController {
                $this->P = GeneralUtility::_GP('P');
                $this->returnEditConf = GeneralUtility::_GP('returnEditConf');
                // Get this record
-               $origRow = BackendUtility::getRecord($this->P['table'], $this->P['uid']);
+               $record = BackendUtility::getRecord($this->P['table'], $this->P['uid']);
                // Set table:
                $this->table = $this->P['params']['table'];
                // Get TSconfig for it.
-               $TSconfig = BackendUtility::getTCEFORM_TSconfig($this->P['table'], is_array($origRow) ? $origRow : array('pid' => $this->P['pid']));
+               $TSconfig = BackendUtility::getTCEFORM_TSconfig($this->P['table'], is_array($record) ? $record : array('pid' => $this->P['pid']));
                // Set [params][pid]
                if (substr($this->P['params']['pid'], 0, 3) === '###' && substr($this->P['params']['pid'], -3) === '###') {
                        $keyword = substr($this->P['params']['pid'], 3, -3);
@@ -117,16 +121,17 @@ class AddController extends AbstractWizardController {
                // Else proceed:
                // If a new id has returned from a newly created record...
                if ($this->returnEditConf) {
-                       $eC = json_decode($this->returnEditConf, TRUE);
-                       if (is_array($eC[$this->table]) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['uid'])) {
+                       $editConfiguration = json_decode($this->returnEditConf, TRUE);
+                       if (is_array($editConfiguration[$this->table]) && MathUtility::canBeInterpretedAsInteger($this->P['uid'])) {
                                // Getting id and cmd from returning editConf array.
-                               reset($eC[$this->table]);
-                               $this->id = (int)key($eC[$this->table]);
-                               $cmd = current($eC[$this->table]);
+                               reset($editConfiguration[$this->table]);
+                               $this->id = (int)key($editConfiguration[$this->table]);
+                               $cmd = current($editConfiguration[$this->table]);
                                // ... and if everything seems OK we will register some classes for inclusion and instruct the object to perform processing later.
-                               if ($this->P['params']['setValue'] && $cmd == 'edit' && $this->id && $this->P['table'] && $this->P['field'] && $this->P['uid']) {
-                                       if ($LiveRec = BackendUtility::getLiveVersionOfRecord($this->table, $this->id, 'uid')) {
-                                               $this->id = $LiveRec['uid'];
+                               if ($this->P['params']['setValue'] && $cmd === 'edit' && $this->id && $this->P['table'] && $this->P['field'] && $this->P['uid']) {
+                                       $liveRecord = BackendUtility::getLiveVersionOfRecord($this->table, $this->id, 'uid');
+                                       if ($liveRecord) {
+                                               $this->id = $liveRecord['uid'];
                                        }
                                        $this->processDataFlag = 1;
                                }
@@ -144,55 +149,58 @@ class AddController extends AbstractWizardController {
                if ($this->returnEditConf) {
                        if ($this->processDataFlag) {
                                // Preparing the data of the parent record...:
-                               $trData = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\DataPreprocessor::class);
+                               /** @var DataPreprocessor $dataPreprocessor */
+                               $dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class);
                                // 'new'
-                               $trData->fetchRecord($this->P['table'], $this->P['uid'], '');
-                               $current = reset($trData->regTableItems_data);
-                               // If that record was found (should absolutely be...), then init TCEmain and set, prepend or append the record
+                               $dataPreprocessor->fetchRecord($this->P['table'], $this->P['uid'], '');
+                               $current = reset($dataPreprocessor->regTableItems_data);
+                               // If that record was found (should absolutely be...), then init DataHandler and set, prepend or append the record
                                if (is_array($current)) {
-                                       $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
-                                       $tce->stripslashes_values = 0;
+                                       /** @var DataHandler $dataHandler */
+                                       $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
+                                       $dataHandler->stripslashes_values = FALSE;
                                        $data = array();
-                                       $addEl = $this->table . '_' . $this->id;
+                                       $recordId = $this->table . '_' . $this->id;
                                        // Setting the new field data:
-                                       // If the field is a flexform field, work with the XML structure instead:
+                                       // If the field is a flexForm field, work with the XML structure instead:
                                        if ($this->P['flexFormPath']) {
-                                               // Current value of flexform path:
+                                               // Current value of flexForm path:
                                                $currentFlexFormData = GeneralUtility::xml2array($current[$this->P['field']]);
-                                               $flexToolObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class);
-                                               $curValueOfFlexform = $flexToolObj->getArrayValueByPath($this->P['flexFormPath'], $currentFlexFormData);
+                                               /** @var FlexFormTools $flexFormTools */
+                                               $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
+                                               $currentFlexFormValue = $flexFormTools->getArrayValueByPath($this->P['flexFormPath'], $currentFlexFormData);
                                                $insertValue = '';
                                                switch ((string)$this->P['params']['setValue']) {
                                                        case 'set':
-                                                               $insertValue = $addEl;
+                                                               $insertValue = $recordId;
                                                                break;
                                                        case 'prepend':
-                                                               $insertValue = $curValueOfFlexform . ',' . $addEl;
+                                                               $insertValue = $currentFlexFormValue . ',' . $recordId;
                                                                break;
                                                        case 'append':
-                                                               $insertValue = $addEl . ',' . $curValueOfFlexform;
+                                                               $insertValue = $recordId . ',' . $currentFlexFormValue;
                                                                break;
                                                }
                                                $insertValue = implode(',', GeneralUtility::trimExplode(',', $insertValue, TRUE));
                                                $data[$this->P['table']][$this->P['uid']][$this->P['field']] = array();
-                                               $flexToolObj->setArrayValueByPath($this->P['flexFormPath'], $data[$this->P['table']][$this->P['uid']][$this->P['field']], $insertValue);
+                                               $flexFormTools->setArrayValueByPath($this->P['flexFormPath'], $data[$this->P['table']][$this->P['uid']][$this->P['field']], $insertValue);
                                        } else {
                                                switch ((string)$this->P['params']['setValue']) {
                                                        case 'set':
-                                                               $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $addEl;
+                                                               $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $recordId;
                                                                break;
                                                        case 'prepend':
-                                                               $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $current[$this->P['field']] . ',' . $addEl;
+                                                               $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $current[$this->P['field']] . ',' . $recordId;
                                                                break;
                                                        case 'append':
-                                                               $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $addEl . ',' . $current[$this->P['field']];
+                                                               $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $recordId . ',' . $current[$this->P['field']];
                                                                break;
                                                }
                                                $data[$this->P['table']][$this->P['uid']][$this->P['field']] = implode(',', GeneralUtility::trimExplode(',', $data[$this->P['table']][$this->P['uid']][$this->P['field']], TRUE));
                                        }
                                        // Submit the data:
-                                       $tce->start($data, array());
-                                       $tce->process_datamap();
+                                       $dataHandler->start($data, array());
+                                       $dataHandler->process_datamap();
                                }
                        }
                        // Return to the parent FormEngine record editing session:
index fcc7b21..1526775 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -27,7 +28,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class ColorpickerController extends AbstractWizardController {
 
        /**
-        * Wizard parameters, coming from TCEforms linking to the wizard.
+        * Wizard parameters, coming from FormEngine linking to the wizard.
         *
         * @var array
         */
@@ -42,7 +43,7 @@ class ColorpickerController extends AbstractWizardController {
 
        /**
         * Serialized functions for changing the field...
-        * Necessary to call when the value is transferred to the TCEform since the form might
+        * Necessary to call when the value is transferred to the FormEngine since the form might
         * need to do internal processing. Otherwise the value is simply not be saved.
         *
         * @var string
@@ -102,7 +103,7 @@ class ColorpickerController extends AbstractWizardController {
        /**
         * Document template object
         *
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
@@ -161,7 +162,7 @@ class ColorpickerController extends AbstractWizardController {
                        }
                }
                // Initialize document object:
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->backPath = $this->getBackPath();
                $this->doc->JScode = $this->doc->wrapScriptTags('
                        function checkReference() {     //
@@ -252,7 +253,7 @@ class ColorpickerController extends AbstractWizardController {
        }
 
        /**
-        * Returnes the sourcecode to the browser
+        * Returns the sourcecode to the browser
         *
         * @return void
         */
@@ -356,7 +357,7 @@ class ColorpickerController extends AbstractWizardController {
                $opt[] = '<option value=""></option>';
                // Traverse colors, making option tags for selector box.
                foreach ($colors as $colorName) {
-                       $opt[] = '<option style="background-color: ' . $colorName . ';" value="' . htmlspecialchars($colorName) . '"' . ($currentValue == $colorName ? ' selected="selected"' : '') . '>' . htmlspecialchars($colorName) . '</option>';
+                       $opt[] = '<option style="background-color: ' . $colorName . ';" value="' . htmlspecialchars($colorName) . '"' . ($currentValue === $colorName ? ' selected="selected"' : '') . '>' . htmlspecialchars($colorName) . '</option>';
                }
                // Compile selector box and return result:
                $output = '
@@ -413,7 +414,7 @@ class ColorpickerController extends AbstractWizardController {
                $index['b'] = dechex($colorRgb['blue']);
                $hexValue = array();
                foreach ($index as $value) {
-                       if (strlen($value) == 1) {
+                       if (strlen($value) === 1) {
                                $hexValue[] = strtoupper('0' . $value);
                        } else {
                                $hexValue[] = strtoupper($value);
index ac2a7a5..bfa4295 100644 (file)
@@ -15,18 +15,19 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 
 /**
- * Script Class for redirecting a backend user to the editing form when an "Edit wizard" link was clicked in TCEforms somewhere
+ * Script Class for redirecting a backend user to the editing form when an "Edit wizard" link was clicked in FormEngine somewhere
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 class EditController extends AbstractWizardController {
 
        /**
-        * Wizard parameters, coming from TCEforms linking to the wizard.
+        * Wizard parameters, coming from FormEngine linking to the wizard.
         *
         * @var array
         */
@@ -69,44 +70,44 @@ class EditController extends AbstractWizardController {
        public function main() {
                if ($this->doClose) {
                        $this->closeWindow();
-               } else {
-                       // Initialize:
-                       $table = $this->P['table'];
-                       $field = $this->P['field'];
-                       $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
-                       $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
+               }
+               // Initialize:
+               $table = $this->P['table'];
+               $field = $this->P['field'];
+               $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
+               $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
 
-                       $urlParameters = array(
-                               'returnUrl' => rawurlencode(BackendUtility::getModuleUrl('wizard_edit', array('doClose' => 1)))
-                       );
+               $urlParameters = array(
+                       'returnUrl' => rawurlencode(BackendUtility::getModuleUrl('wizard_edit', array('doClose' => 1)))
+               );
 
-                       // Detecting the various allowed field type setups and acting accordingly.
-                       if (is_array($config) && $config['type'] == 'select' && !$config['MM'] && $config['maxitems'] <= 1 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['currentValue']) && $this->P['currentValue'] && $fTable) {
-                               // SINGLE value
-                               $urlParameters['edit[' . $fTable . '][' . $this->P['currentValue'] . ']'] = 'edit';
-                               // Redirect to FormEngine
-                               $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
-                               HttpUtility::redirect($url);
-                       } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] == 'select' && $config['foreign_table'] || $config['type'] == 'group' && $config['internal_type'] == 'db')) {
-                               // MULTIPLE VALUES:
-                               // Init settings:
-                               $allowedTables = $config['type'] == 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
-                               $prependName = 1;
-                               // Selecting selected values into an array:
-                               $dbAnalysis = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\RelationHandler::class);
-                               $dbAnalysis->start($this->P['currentSelectedValues'], $allowedTables);
-                               $value = $dbAnalysis->getValueArray($prependName);
-                               // Traverse that array and make parameters for FormEngine
-                               foreach ($value as $rec) {
-                                       $recTableUidParts = GeneralUtility::revExplode('_', $rec, 2);
-                                       $urlParameters['edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']'] = 'edit';
-                               }
-                               // Redirect to FormEngine
-                               $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
-                               HttpUtility::redirect($url);
-                       } else {
-                               $this->closeWindow();
+               // Detecting the various allowed field type setups and acting accordingly.
+               if (is_array($config) && $config['type'] === 'select' && !$config['MM'] && $config['maxitems'] <= 1 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['currentValue']) && $this->P['currentValue'] && $fTable) {
+                       // SINGLE value
+                       $urlParameters['edit[' . $fTable . '][' . $this->P['currentValue'] . ']'] = 'edit';
+                       // Redirect to FormEngine
+                       $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
+                       HttpUtility::redirect($url);
+               } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] === 'select' && $config['foreign_table'] || $config['type'] === 'group' && $config['internal_type'] === 'db')) {
+                       // MULTIPLE VALUES:
+                       // Init settings:
+                       $allowedTables = $config['type'] === 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
+                       $prependName = 1;
+                       // Selecting selected values into an array:
+                       /** @var RelationHandler $relationHandler */
+                       $relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
+                       $relationHandler->start($this->P['currentSelectedValues'], $allowedTables);
+                       $value = $relationHandler->getValueArray($prependName);
+                       // Traverse that array and make parameters for FormEngine
+                       foreach ($value as $rec) {
+                               $recTableUidParts = GeneralUtility::revExplode('_', $rec, 2);
+                               $urlParameters['edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']'] = 'edit';
                        }
+                       // Redirect to FormEngine
+                       $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
+                       HttpUtility::redirect($url);
+               } else {
+                       $this->closeWindow();
                }
        }
 
index 4945709..75578ff 100644 (file)
@@ -18,7 +18,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
- * Script Class for redirecting the user to the Web > List module if a wizard-link has been clicked in TCEforms
+ * Script Class for redirecting the user to the Web > List module if a wizard-link has been clicked in FormEngine
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
@@ -30,7 +30,7 @@ class ListController extends AbstractWizardController {
        public $pid;
 
        /**
-        * Wizard parameters, coming from TCEforms linking to the wizard.
+        * Wizard parameters, coming from FormEngine linking to the wizard.
         *
         * @var array
         */
index 93c5b8a..949b32c 100644 (file)
@@ -14,22 +14,25 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Form\DataPreprocessor;
+use TYPO3\CMS\Backend\Form\FormEngine;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
- * Script Class for rendering the full screen RTE display
+ * Script class for rendering the full screen RTE display
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 class RteController extends AbstractWizardController {
 
        /**
-        * document template object
+        * Document template object
         *
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
@@ -41,7 +44,7 @@ class RteController extends AbstractWizardController {
        public $content;
 
        /**
-        * Wizard parameters, coming from TCEforms linking to the wizard.
+        * Wizard parameters, coming from FormEngine linking to the wizard.
         *
         * @var array
         */
@@ -62,6 +65,13 @@ class RteController extends AbstractWizardController {
        public $R_URI;
 
        /**
+        * Module configuration
+        *
+        * @var array
+        */
+       public $MCONF = array();
+
+       /**
         * Constructor
         */
        public function __construct() {
@@ -84,7 +94,7 @@ class RteController extends AbstractWizardController {
                // "Module name":
                $this->MCONF['name'] = 'wizard_rte';
                // Starting the document template object:
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->backPath = $this->getBackPath();
                $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/wizard_rte.html');
                // Need to NOT have the page wrapped in DIV since if we do that we destroy
@@ -94,20 +104,20 @@ class RteController extends AbstractWizardController {
        }
 
        /**
-        * Main function, rendering the document with the iframe with the RTE in.
+        * Main function, rendering the document with the iFrame with the RTE in.
         *
         * @return void
         */
        public function main() {
                // Translate id to the workspace version:
-               if ($versionRec = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUserAuthentication()->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
-                       $this->P['uid'] = $versionRec['uid'];
+               if ($versionedRecord = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUserAuthentication()->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
+                       $this->P['uid'] = $versionedRecord['uid'];
                }
                // If all parameters are available:
                if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
                        // Getting the raw record (we need only the pid-value from here...)
-                       $rawRec = BackendUtility::getRecord($this->P['table'], $this->P['uid']);
-                       BackendUtility::fixVersioningPid($this->P['table'], $rawRec);
+                       $rawRecord = BackendUtility::getRecord($this->P['table'], $this->P['uid']);
+                       BackendUtility::fixVersioningPid($this->P['table'], $rawRecord);
 
                        // override the default jumpToUrl
                        $this->doc->JScodeArray['jumpToUrl'] = '
@@ -126,41 +136,40 @@ class RteController extends AbstractWizardController {
 
                        // Setting JavaScript of the pid value for viewing:
                        if ($this->popView) {
-                               $this->doc->JScode = $this->doc->wrapScriptTags(BackendUtility::viewOnClick($rawRec['pid'], '', BackendUtility::BEgetRootLine($rawRec['pid'])));
+                               $this->doc->JScode = $this->doc->wrapScriptTags(BackendUtility::viewOnClick($rawRecord['pid'], '', BackendUtility::BEgetRootLine($rawRecord['pid'])));
                        }
-                       // Initialize TCeforms - for rendering the field:
-                       $tceforms = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\FormEngine::class);
+                       // Initialize FormEngine - for rendering the field:
+                       /** @var FormEngine $formEngine */
+                       $formEngine = GeneralUtility::makeInstance(FormEngine::class);
                        // SPECIAL: Disables all wizards - we are NOT going to need them.
-                       $tceforms->disableWizards = 1;
+                       $formEngine->disableWizards = 1;
                        // Initialize style for RTE object:
                        // Getting reference to the RTE object used to render the field!
-                       $RTEobj = BackendUtility::RTEgetObj();
-                       if ($RTEobj->ID == 'rte') {
-                               $RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';
+                       $RTEObject = BackendUtility::RTEgetObj();
+                       if ($RTEObject->ID === 'rte') {
+                               $RTEObject->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';
                        }
                        // Fetching content of record:
-                       $trData = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\DataPreprocessor::class);
-                       $trData->lockRecords = 1;
-                       $trData->fetchRecord($this->P['table'], $this->P['uid'], '');
+                       /** @var DataPreprocessor $dataPreprocessor */
+                       $dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class);
+                       $dataPreprocessor->lockRecords = 1;
+                       $dataPreprocessor->fetchRecord($this->P['table'], $this->P['uid'], '');
                        // Getting the processed record content out:
-                       $rec = reset($trData->regTableItems_data);
-                       $rec['uid'] = $this->P['uid'];
-                       $rec['pid'] = $rawRec['pid'];
+                       $processedRecord = reset($dataPreprocessor->regTableItems_data);
+                       $processedRecord['uid'] = $this->P['uid'];
+                       $processedRecord['pid'] = $rawRecord['pid'];
                        // TSconfig, setting width:
-                       $fieldTSConfig = FormEngineUtility::getTSconfigForTableRow($this->P['table'], $rec, $this->P['field']);
+                       $fieldTSConfig = FormEngineUtility::getTSconfigForTableRow($this->P['table'], $processedRecord, $this->P['field']);
                        if ((string)$fieldTSConfig['RTEfullScreenWidth'] !== '') {
                                $width = $fieldTSConfig['RTEfullScreenWidth'];
                        } else {
                                $width = '100%';
                        }
                        // Get the form field and wrap it in the table with the buttons:
-                       $formContent = $tceforms->getSoloField($this->P['table'], $rec, $this->P['field']);
+                       $formContent = $formEngine->getSoloField($this->P['table'], $processedRecord, $this->P['field']);
                        $formContent = '
 
-
-                       <!--
-                               RTE wizard:
-                       -->
+                       <!-- RTE wizard: -->
                                <table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
                                        <tr>
                                                <td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
@@ -169,19 +178,19 @@ class RteController extends AbstractWizardController {
                                </table>';
                        // Adding hidden fields:
                        $formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
-                                               <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
+                                               <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />' . FormEngine::getHiddenTokenField('tceAction');
                        // Finally, add the whole setup:
-                       $this->content .= $tceforms->printNeededJSFunctions_top() . $formContent . $tceforms->printNeededJSFunctions();
+                       $this->content .= $formEngine->printNeededJSFunctions_top() . $formContent . $formEngine->printNeededJSFunctions();
                } else {
                        // ERROR:
                        $this->content .= $this->doc->section($this->getLanguageService()->getLL('forms_title'), '<span class="typo3-red">' . $this->getLanguageService()->getLL('table_noData', TRUE) . '</span>', 0, 1);
                }
-               // Setting up the buttons and markers for docheader
+               // Setting up the buttons and markers for docHeader
                $docHeaderButtons = $this->getButtons();
                $markers['CONTENT'] = $this->content;
                // Build the <body> for the module
                $this->content = $this->doc->startPage('');
-               $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
                $this->content .= $this->doc->endPage();
                $this->content = $this->doc->insertStylesAndJS($this->content);
        }
@@ -215,8 +224,9 @@ class RteController extends AbstractWizardController {
                        $closeUrl = GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']);
                        // Getting settings for the undo button:
                        $undoButton = 0;
-                       $undoRes = $this->getDatabaseConnection()->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($this->P['table'], 'sys_history') . ' AND recuid=' . (int)$this->P['uid'], '', 'tstamp DESC', '1');
-                       if ($undoButtonR = $this->getDatabaseConnection()->sql_fetch_assoc($undoRes)) {
+                       $databaseConnection = $this->getDatabaseConnection();
+                       $undoRes = $databaseConnection->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $databaseConnection->fullQuoteStr($this->P['table'], 'sys_history') . ' AND recuid=' . (int)$this->P['uid'], '', 'tstamp DESC', '1');
+                       if ($undoButtonR = $databaseConnection->sql_fetch_assoc($undoRes)) {
                                $undoButton = 1;
                        }
                        // Close
index 1011d6a..e7a7d42 100644 (file)
@@ -14,10 +14,14 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Script Class for rendering the Table Wizard
@@ -27,9 +31,9 @@ use TYPO3\CMS\Core\Utility\MathUtility;
 class TableController extends AbstractWizardController {
 
        /**
-        * document template object
+        * Document template object
         *
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
@@ -41,15 +45,15 @@ class TableController extends AbstractWizardController {
        public $content;
 
        /**
-        * TRUE, then <input> fields are shown, not textareas.
+        * If TRUE, <input> fields are shown instead of textareas.
         *
-        * @var int
+        * @var bool
         */
-       public $inputStyle = 0;
+       public $inputStyle = FALSE;
 
        /**
         * If set, the string version of the content is interpreted/written as XML
-        * instead of the original linebased kind. This variable still needs binding
+        * instead of the original line-based kind. This variable still needs binding
         * to the wizard parameters - but support is ready!
         *
         * @var int
@@ -65,14 +69,14 @@ class TableController extends AbstractWizardController {
 
        /**
         * Name of field in parent record which MAY contain the number of columns for the table
-        * here hardcoded to the value of tt_content. Should be set by TCEform parameters (from P)
+        * here hardcoded to the value of tt_content. Should be set by FormEngine parameters (from P)
         *
         * @var string
         */
        public $colsFieldName = 'cols';
 
        /**
-        * Wizard parameters, coming from TCEforms linking to the wizard.
+        * Wizard parameters, coming from FormEngine linking to the wizard.
         *
         * @var array
         */
@@ -123,9 +127,9 @@ class TableController extends AbstractWizardController {
                $this->xmlStorage = $this->P['params']['xmlOutput'];
                $this->numNewRows = MathUtility::forceIntegerInRange($this->P['params']['numNewRows'], 1, 50, 5);
                // Textareas or input fields:
-               $this->inputStyle = isset($this->TABLECFG['textFields']) ? $this->TABLECFG['textFields'] : 1;
+               $this->inputStyle = isset($this->TABLECFG['textFields']) ? (bool)$this->TABLECFG['textFields'] : TRUE;
                // Document template object:
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->backPath = $this->getBackPath();
                $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/wizard_table.html');
                // Setting form tag:
@@ -146,13 +150,13 @@ class TableController extends AbstractWizardController {
                } else {
                        $this->content .= $this->doc->section($this->getLanguageService()->getLL('table_title'), '<span class="typo3-red">' . $this->getLanguageService()->getLL('table_noData', TRUE) . '</span>', 0, 1);
                }
-               // Setting up the buttons and markers for docheader
+               // Setting up the buttons and markers for docHeader
                $docHeaderButtons = $this->getButtons();
                $markers['CSH'] = $docHeaderButtons['csh'];
                $markers['CONTENT'] = $this->content;
                // Build the <body> for the module
                $this->content = $this->doc->startPage('Table');
-               $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
                $this->content .= $this->doc->endPage();
                $this->content = $this->doc->insertStylesAndJS($this->content);
        }
@@ -169,7 +173,7 @@ class TableController extends AbstractWizardController {
        /**
         * Create the panel of buttons for submitting the form or otherwise perform operations.
         *
-        * @return array All available buttons as an assoc. array
+        * @return array All available buttons as an associative array
         */
        protected function getButtons() {
                $buttons = array(
@@ -201,6 +205,7 @@ class TableController extends AbstractWizardController {
         * Draws the table wizard content
         *
         * @return string HTML content for the form.
+        * @throws \RuntimeException
         */
        public function tableWizard() {
                if (!$this->checkEditAccess($this->P['table'], $this->P['uid'])) {
@@ -215,23 +220,24 @@ class TableController extends AbstractWizardController {
                // saved to database etc. if the form has been submitted in the meantime.
                $tableCfgArray = $this->getConfigCode($row);
                // Generation of the Table Wizards HTML code:
-               $content = $this->getTableHTML($tableCfgArray, $row);
+               $content = $this->getTableHTML($tableCfgArray);
                // Return content:
                return $content;
        }
 
-       /***************************
+       /*
         *
         * Helper functions
         *
-        ***************************/
+        */
+
        /**
         * Will get and return the configuration code string
         * Will also save (and possibly redirect/exit) the content if a save button has been pressed
         *
         * @param array $row Current parent record row
         * @return array Table config code in an array
-        * @access private
+        * @internal
         */
        public function getConfigCode($row) {
                // Get delimiter settings
@@ -249,56 +255,56 @@ class TableController extends AbstractWizardController {
                                // Convert the input array to XML:
                                $bodyText = GeneralUtility::array2xml_cs($this->TABLECFG['c'], 'T3TableWizard');
                                // Setting cfgArr directly from the input:
-                               $cfgArr = $this->TABLECFG['c'];
+                               $configuration = $this->TABLECFG['c'];
                        } else {
                                // Convert the input array to a string of configuration code:
                                $bodyText = $this->cfgArray2CfgString($this->TABLECFG['c']);
                                // Create cfgArr from the string based configuration - that way it is cleaned up and any incompatibilities will be removed!
-                               $cfgArr = $this->cfgString2CfgArray($bodyText, $row[$this->colsFieldName]);
+                               $configuration = $this->cfgString2CfgArray($bodyText, $row[$this->colsFieldName]);
                        }
                        // If a save button has been pressed, then save the new field content:
                        if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
-                               // Make TCEmain object:
-                               $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
-                               $tce->stripslashes_values = 0;
+                               // Get DataHandler object:
+                               /** @var DataHandler $dataHandler */
+                               $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
+                               $dataHandler->stripslashes_values = FALSE;
                                // Put content into the data array:
                                $data = array();
                                $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $bodyText;
                                // Perform the update:
-                               $tce->start($data, array());
-                               $tce->process_datamap();
+                               $dataHandler->start($data, array());
+                               $dataHandler->process_datamap();
                                // If the save/close button was pressed, then redirect the screen:
                                if ($_POST['saveandclosedok_x']) {
-                                       \TYPO3\CMS\Core\Utility\HttpUtility::redirect(GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']));
+                                       HttpUtility::redirect(GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']));
                                }
                        }
                } else {
                        // If nothing has been submitted, load the $bodyText variable from the selected database row:
                        if ($this->xmlStorage) {
-                               $cfgArr = GeneralUtility::xml2array($row[$this->P['field']]);
+                               $configuration = GeneralUtility::xml2array($row[$this->P['field']]);
                        } else {
-                               // Regular linebased table configuration:
-                               $cfgArr = $this->cfgString2CfgArray($row[$this->P['field']], $row[$this->colsFieldName]);
+                               // Regular line based table configuration:
+                               $configuration = $this->cfgString2CfgArray($row[$this->P['field']], $row[$this->colsFieldName]);
                        }
-                       $cfgArr = is_array($cfgArr) ? $cfgArr : array();
+                       $configuration = is_array($configuration) ? $configuration : array();
                }
-               return $cfgArr;
+               return $configuration;
        }
 
        /**
         * Creates the HTML for the Table Wizard:
         *
-        * @param array $cfgArr Table config array
-        * @param array $row Current parent record array
+        * @param array $configuration Table config array
         * @return string HTML for the table wizard
-        * @access private
+        * @internal
         */
-       public function getTableHTML($cfgArr, $row) {
+       public function getTableHTML($configuration) {
                // Traverse the rows:
                $tRows = array();
                $k = 0;
-               $countLines = count($cfgArr);
-               foreach ($cfgArr as $cellArr) {
+               $countLines = count($configuration);
+               foreach ($configuration as $cellArr) {
                        if (is_array($cellArr)) {
                                // Initialize:
                                $cells = array();
@@ -319,13 +325,13 @@ class TableController extends AbstractWizardController {
                                $onClick = ' onclick="' . htmlspecialchars($onClick) . '"';
                                $ctrl = '';
                                $brTag = $this->inputStyle ? '' : '<br />';
-                               if ($k != 0) {
+                               if ($k !== 0) {
                                        $ctrl .= '<input type="image" name="TABLE[row_up][' . ($k + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/pil2up.gif', '') . $onClick . ' title="' . $this->getLanguageService()->getLL('table_up', TRUE) . '" />' . $brTag;
                                } else {
                                        $ctrl .= '<input type="image" name="TABLE[row_bottom][' . ($k + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/turn_up.gif', '') . $onClick . ' title="' . $this->getLanguageService()->getLL('table_bottom', TRUE) . '" />' . $brTag;
                                }
                                $ctrl .= '<input type="image" name="TABLE[row_remove][' . ($k + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . $onClick . ' title="' . $this->getLanguageService()->getLL('table_removeRow', TRUE) . '" />' . $brTag;
-                               if ($k + 1 != $countLines) {
+                               if ($k + 1 !== $countLines) {
                                        $ctrl .= '<input type="image" name="TABLE[row_down][' . ($k + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/pil2down.gif', '') . $onClick . ' title="' . $this->getLanguageService()->getLL('table_down', TRUE) . '" />' . $brTag;
                                } else {
                                        $ctrl .= '<input type="image" name="TABLE[row_top][' . ($k + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/turn_down.gif', '') . $onClick . ' title="' . $this->getLanguageService()->getLL('table_top', TRUE) . '" />' . $brTag;
@@ -345,29 +351,25 @@ class TableController extends AbstractWizardController {
                $cells = array();
                $cells[] = '';
                // Finding first row:
-               $firstRow = reset($cfgArr);
+               $firstRow = reset($configuration);
                if (is_array($firstRow)) {
-                       // Init:
-                       $a = 0;
                        $cols = count($firstRow);
-                       // Traverse first row:
-                       foreach ($firstRow as $temp) {
+                       for ($a = 1; $a <= $cols; $a++) {
+                               $b = $a * 2;
                                $ctrl = '';
-                               if ($a != 0) {
-                                       $ctrl .= '<input type="image" name="TABLE[col_left][' . ($a + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/pil2left.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_left', TRUE) . '" />';
+                               if ($a !== 1) {
+                                       $ctrl .= '<input type="image" name="TABLE[col_left][' . $b . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/pil2left.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_left', TRUE) . '" />';
                                } else {
-                                       $ctrl .= '<input type="image" name="TABLE[col_end][' . ($a + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/turn_left.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_end', TRUE) . '" />';
+                                       $ctrl .= '<input type="image" name="TABLE[col_end][' . $b . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/turn_left.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_end', TRUE) . '" />';
                                }
-                               $ctrl .= '<input type="image" name="TABLE[col_remove][' . ($a + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_removeColumn', TRUE) . '" />';
+                               $ctrl .= '<input type="image" name="TABLE[col_remove][' . $b . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_removeColumn', TRUE) . '" />';
                                if ($a + 1 != $cols) {
-                                       $ctrl .= '<input type="image" name="TABLE[col_right][' . ($a + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/pil2right.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_right', TRUE) . '" />';
+                                       $ctrl .= '<input type="image" name="TABLE[col_right][' . $b . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/pil2right.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_right', TRUE) . '" />';
                                } else {
-                                       $ctrl .= '<input type="image" name="TABLE[col_start][' . ($a + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/turn_right.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_start', TRUE) . '" />';
+                                       $ctrl .= '<input type="image" name="TABLE[col_start][' . $b . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/turn_right.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_start', TRUE) . '" />';
                                }
-                               $ctrl .= '<input type="image" name="TABLE[col_add][' . ($a + 1) * 2 . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/add.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_addColumn', TRUE) . '" />';
+                               $ctrl .= '<input type="image" name="TABLE[col_add][' . $b . ']"' . IconUtility::skinImg($this->doc->backPath, 'gfx/add.gif', '') . ' title="' . $this->getLanguageService()->getLL('table_addColumn', TRUE) . '" />';
                                $cells[] = '<span class="c-wizButtonsH">' . $ctrl . '</span>';
-                               // Incr. counter:
-                               $a++;
                        }
                        $tRows[] = '
                                <tr class="bgColor5">
@@ -379,26 +381,22 @@ class TableController extends AbstractWizardController {
                // Implode all table rows into a string, wrapped in table tags.
                $content .= '
 
-
-                       <!--
-                               Table wizard
-                       -->
+                       <!-- Table wizard -->
                        <table border="0" cellpadding="0" cellspacing="1" id="typo3-tablewizard">
                                ' . implode('', $tRows) . '
                        </table>';
                // Input type checkbox:
                $content .= '
 
-                       <!--
-                               Input mode check box:
-                       -->
+                       <!-- Input mode check box: -->
                        <div id="c-inputMode">
-                               ' . '<input type="hidden" name="TABLE[textFields]" value="0" />' . '<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"' . ($this->inputStyle ? ' checked="checked"' : '') . ' /> <label for="textFields">' . $this->getLanguageService()->getLL('table_smallFields') . '</label>
+                               ' . '<input type="hidden" name="TABLE[textFields]" value="0" />'
+                       . '<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"' . ($this->inputStyle ? ' checked="checked"' : '') . ' />'
+                       . '<label for="textFields">' . $this->getLanguageService()->getLL('table_smallFields') . '</label>
                        </div>
 
                        <br /><br />
                        ';
-               // Return content:
                return $content;
        }
 
@@ -406,7 +404,7 @@ class TableController extends AbstractWizardController {
         * Detects if a control button (up/down/around/delete) has been pressed for an item and accordingly it will manipulate the internal TABLECFG array
         *
         * @return void
-        * @access private
+        * @internal
         */
        public function changeFunc() {
                if ($this->TABLECFG['col_remove']) {
@@ -445,16 +443,19 @@ class TableController extends AbstractWizardController {
                } elseif ($this->TABLECFG['row_down']) {
                        $kk = key($this->TABLECFG['row_down']);
                        $cmd = 'row_down';
+               } else {
+                       $kk = '';
+                       $cmd = '';
                }
                if ($cmd && MathUtility::canBeInterpretedAsInteger($kk)) {
-                       if (substr($cmd, 0, 4) == 'row_') {
+                       if (StringUtility::beginsWith($cmd, 'row_')) {
                                switch ($cmd) {
                                        case 'row_remove':
                                                unset($this->TABLECFG['c'][$kk]);
                                                break;
                                        case 'row_add':
                                                for ($a = 1; $a <= $this->numNewRows; $a++) {
-                                                       // Checking if set: The point is that any new row inbetween existing rows
+                                                       // Checking if set: The point is that any new row between existing rows
                                                        // will be TRUE after one row is added while if rows are added in the bottom
                                                        // of the table there will be no existing rows to stop the addition of new rows
                                                        // which means it will add up to $this->numNewRows rows then.
@@ -484,7 +485,7 @@ class TableController extends AbstractWizardController {
                                }
                                ksort($this->TABLECFG['c']);
                        }
-                       if (substr($cmd, 0, 4) == 'col_') {
+                       if (StringUtility::beginsWith($cmd, 'col_')) {
                                foreach ($this->TABLECFG['c'] as $cAK => $value) {
                                        switch ($cmd) {
                                                case 'col_remove':
@@ -530,54 +531,50 @@ class TableController extends AbstractWizardController {
         * @see cfgString2CfgArray()
         */
        public function cfgArray2CfgString($cfgArr) {
-               // Initialize:
                $inLines = array();
                // Traverse the elements of the table wizard and transform the settings into configuration code.
-               foreach ($this->TABLECFG['c'] as $a => $value) {
+               foreach ($cfgArr as $valueA) {
                        $thisLine = array();
-                       foreach ($this->TABLECFG['c'][$a] as $b => $value) {
-                               $thisLine[] = $this->tableParsing_quote . str_replace($this->tableParsing_delimiter, '', $this->TABLECFG['c'][$a][$b]) . $this->tableParsing_quote;
+                       foreach ($valueA as $valueB) {
+                               $thisLine[] = $this->tableParsing_quote . str_replace($this->tableParsing_delimiter, '', $valueB) . $this->tableParsing_quote;
                        }
                        $inLines[] = implode($this->tableParsing_delimiter, $thisLine);
                }
                // Finally, implode the lines into a string:
-               $bodyText = implode(LF, $inLines);
-               // Return the configuration code:
-               return $bodyText;
+               return implode(LF, $inLines);
        }
 
        /**
         * Converts the input configuration code string into an array
         *
-        * @param string $cfgStr Configuration code
-        * @param int $cols Default number of columns
+        * @param string $configurationCode Configuration code
+        * @param int $columns Default number of columns
         * @return array Configuration array
         * @see cfgArray2CfgString()
         */
-       public function cfgString2CfgArray($cfgStr, $cols) {
+       public function cfgString2CfgArray($configurationCode, $columns) {
                // Explode lines in the configuration code - each line is a table row.
-               $tLines = explode(LF, $cfgStr);
+               $tableLines = explode(LF, $configurationCode);
                // Setting number of columns
                // auto...
-               if (!$cols && trim($tLines[0])) {
-                       $cols = count(explode($this->tableParsing_delimiter, $tLines[0]));
+               if (!$columns && trim($tableLines[0])) {
+                       $columns = count(explode($this->tableParsing_delimiter, $tableLines[0]));
                }
-               $cols = $cols ?: 4;
+               $columns = $columns ?: 4;
                // Traverse the number of table elements:
-               $cfgArr = array();
-               foreach ($tLines as $k => $v) {
+               $configurationArray = array();
+               foreach ($tableLines as $key => $value) {
                        // Initialize:
-                       $vParts = explode($this->tableParsing_delimiter, $v);
+                       $valueParts = explode($this->tableParsing_delimiter, $value);
                        // Traverse columns:
-                       for ($a = 0; $a < $cols; $a++) {
-                               if ($this->tableParsing_quote && $vParts[$a][0] === $this->tableParsing_quote && substr($vParts[$a], -1, 1) === $this->tableParsing_quote) {
-                                       $vParts[$a] = substr(trim($vParts[$a]), 1, -1);
+                       for ($a = 0; $a < $columns; $a++) {
+                               if ($this->tableParsing_quote && $valueParts[$a][0] === $this->tableParsing_quote && substr($valueParts[$a], -1, 1) === $this->tableParsing_quote) {
+                                       $valueParts[$a] = substr(trim($valueParts[$a]), 1, -1);
                                }
-                               $cfgArr[$k][$a] = $vParts[$a];
+                               $configurationArray[$key][$a] = $valueParts[$a];
                        }
                }
-               // Return configuration array:
-               return $cfgArr;
+               return $configurationArray;
        }
 
 }