[BUGFIX] wizard_table not working with FlexForm 26/41926/2
authorFrank Nägler <typo3@naegler.net>
Fri, 24 Jul 2015 10:27:54 +0000 (12:27 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 24 Jul 2015 14:10:15 +0000 (16:10 +0200)
This patch fix the table wizard and adjust the DocHeader icons.
It is now possible to use table wizard in FlexForms which never
worked before.

Resolves: #68107
Releases: master
Change-Id: I72914735f2e16f698670350eda2ad9b99061bdd1
Reviewed-on: http://review.typo3.org/41926
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Controller/Wizard/TableController.php

index ee8f1c8..4016d59 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+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;
@@ -190,11 +191,11 @@ class TableController extends AbstractWizardController {
                        // Close
                        $buttons['close'] = '<a href="#" onclick="' . htmlspecialchars(('jumpToUrl(' . GeneralUtility::quoteJSvalue(GeneralUtility::sanitizeLocalUrl($this->P['returnUrl'])) . '); return false;')) . '">' . IconUtility::getSpriteIcon('actions-document-close', array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE))) . '</a>';
                        // Save
-                       $buttons['save'] = '<button class="c-inputButton" name="savedok">' . IconUtility::getSpriteIcon('actions-document-save', array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE))) . '</button>';
+                       $buttons['save'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '<button class="c-inputButton" name="savedok" value="1"></button>', 'title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE)));
                        // Save & Close
-                       $buttons['save_close'] = '<button class="c-inputButton" name="saveandclosedok">' . IconUtility::getSpriteIcon('actions-document-save-close', array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE))) . '</button>';
+                       $buttons['save_close'] = IconUtility::getSpriteIcon('actions-document-save-close', array('html' => '<button class="c-inputButton" name="saveandclosedok" value="1"></button>', 'title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE)));
                        // Reload
-                       $buttons['reload'] = '<button class="c-inputButton" name="_refresh">' . IconUtility::getSpriteIcon('actions-system-refresh', array('title' => $this->getLanguageService()->getLL('forms_refresh', TRUE))) . '</button>';
+                       $buttons['reload'] = IconUtility::getSpriteIcon('actions-system-refresh', array('html' => '<button class="c-inputButton" name="_refresh" value="1"></button>', 'title' => $this->getLanguageService()->getLL('forms_refresh', TRUE)));
                }
                return $buttons;
        }
@@ -261,19 +262,28 @@ class TableController extends AbstractWizardController {
                                $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']) {
+                       if ($_POST['savedok'] || $_POST['saveandclosedok']) {
                                // 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;
+                               if ($this->P['flexFormPath']) {
+                                       // Current value of flexForm path:
+                                       $currentFlexFormData = GeneralUtility::xml2array($row[$this->P['field']]);
+                                       /** @var FlexFormTools $flexFormTools */
+                                       $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
+                                       $flexFormTools->setArrayValueByPath($this->P['flexFormPath'], $currentFlexFormData, $bodyText);
+                                       $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $currentFlexFormData;
+                               } else {
+                                       $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $bodyText;
+                               }
                                // Perform the update:
                                $dataHandler->start($data, array());
                                $dataHandler->process_datamap();
                                // If the save/close button was pressed, then redirect the screen:
-                               if ($_POST['saveandclosedok_x']) {
+                               if ($_POST['saveandclosedok']) {
                                        HttpUtility::redirect(GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']));
                                }
                        }
@@ -282,8 +292,17 @@ class TableController extends AbstractWizardController {
                        if ($this->xmlStorage) {
                                $configuration = GeneralUtility::xml2array($row[$this->P['field']]);
                        } else {
-                               // Regular line based table configuration:
-                               $configuration = $this->cfgString2CfgArray($row[$this->P['field']], $row[$this->colsFieldName]);
+                               if ($this->P['flexFormPath']) {
+                                       // Current value of flexForm path:
+                                       $currentFlexFormData = GeneralUtility::xml2array($row[$this->P['field']]);
+                                       /** @var FlexFormTools $flexFormTools */
+                                       $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
+                                       $configuration = $flexFormTools->getArrayValueByPath($this->P['flexFormPath'], $currentFlexFormData);
+                                       $configuration = $this->cfgString2CfgArray($configuration, 0);
+                               } else {
+                                       // Regular line based table configuration:
+                                       $configuration = $this->cfgString2CfgArray($row[$this->P['field']], $row[$this->colsFieldName]);
+                               }
                        }
                        $configuration = is_array($configuration) ? $configuration : array();
                }