[CLEANUP] EXT:backend/Classes/Wizard/*.php
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / Wizard / EditController.php
index ac2a7a5..bfa4295 100644 (file)
@@ -15,18 +15,19 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 
 /**
 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 {
 
        /**
  *
  * @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
         */
         *
         * @var array
         */
@@ -69,44 +70,44 @@ class EditController extends AbstractWizardController {
        public function main() {
                if ($this->doClose) {
                        $this->closeWindow();
        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();
                }
        }
 
                }
        }