[TASK] Impexp Move generation of selector boxes to Fluid template 73/45973/2
authorReinhard Führicht <rf@typoheads.at>
Fri, 15 Jan 2016 16:20:46 +0000 (17:20 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 15 Jan 2016 20:44:57 +0000 (21:44 +0100)
Select box generation has been handed over to Fluid view helper.

Resolves: #72741
Releases: master, 7.6
Change-Id: I3908cf45cefdac4284b5e89a54eb591a43cb1df1
Reviewed-on: https://review.typo3.org/45973
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/impexp/Classes/Controller/ImportExportController.php
typo3/sysext/impexp/Resources/Private/Partials/Export/AdvancedOptions.html
typo3/sysext/impexp/Resources/Private/Partials/Export/Configuration.html
typo3/sysext/impexp/Resources/Private/Partials/Export/Save.html

index 542e802..c30ec1e 100644 (file)
@@ -539,12 +539,10 @@ class ImportExportController extends BaseScriptClass
                 $defaultFlashMessageQueue->enqueue($flashMessage);
             }
         }
-        // OUTPUT to BROWSER:
+
         $this->makeConfigurationForm($inData);
 
-        $row = array();
         $this->makeSaveForm($inData);
-        $this->standaloneView->assign('saveForm', implode('', $row));
 
         $this->makeAdvancedOptionsForm($inData);
 
@@ -647,8 +645,8 @@ class ImportExportController extends BaseScriptClass
                 '4' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'),
                 '999' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi'),
             );
-            $this->standaloneView->assign('levelSelect', $this->renderSelectBox('tx_impexp[pagetree][levels]', $inData['pagetree']['levels'], $opt));
-            $this->standaloneView->assign('tableSelect', $this->tableSelector('tx_impexp[pagetree][tables]', $inData['pagetree']['tables'], 'pages'));
+            $this->standaloneView->assign('levelSelectOptions', $opt);
+            $this->standaloneView->assign('tableSelectOptions', $this->getTableSelectOptions('pages'));
             $nameSuggestion .= 'tree_PID' . $inData['pagetree']['id'] . '_L' . $inData['pagetree']['levels'];
         }
         // Single record export:
@@ -696,8 +694,8 @@ class ImportExportController extends BaseScriptClass
             $this->standaloneView->assign('tableList', $tblList);
         }
 
-        $this->standaloneView->assign('externalReferenceTableSelect', $this->tableSelector('tx_impexp[external_ref][tables]', $inData['external_ref']['tables']));
-        $this->standaloneView->assign('externalStaticTableSelect', $this->tableSelector('tx_impexp[external_static][tables]', $inData['external_static']['tables']));
+        $this->standaloneView->assign('externalReferenceTableSelectOptions', $this->getTableSelectOptions());
+        $this->standaloneView->assign('externalStaticTableSelectOptions', $this->getTableSelectOptions());
 
         // Exclude:
         $excludeHiddenFields = '';
@@ -719,7 +717,9 @@ class ImportExportController extends BaseScriptClass
      */
     public function makeAdvancedOptionsForm($inData)
     {
-        $this->standaloneView->assign('extensions', $this->extensionSelector('tx_impexp[extension_dep]', $inData['extension_dep']));
+        $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
+        $loadedExtensions = array_combine($loadedExtensions, $loadedExtensions);
+        $this->standaloneView->assign('extensions', $loadedExtensions);
         $this->standaloneView->assign('inData', $inData);
     }
 
@@ -745,7 +745,7 @@ class ImportExportController extends BaseScriptClass
             }
         }
 
-        $this->standaloneView->assign('presetSelect', $this->renderSelectBox('preset[select]', '', $opt));
+        $this->standaloneView->assign('presetSelectOptions', $opt);
 
         $saveFolder = $this->getDefaultImportExportFolder();
         if ($saveFolder) {
@@ -760,7 +760,7 @@ class ImportExportController extends BaseScriptClass
         $opt['t3d'] = $this->lang->getLL('makesavefo_t3dFile');
         $opt['xml'] = $this->lang->getLL('makesavefo_xml');
 
-        $this->standaloneView->assign('filetypeSelect', $this->renderSelectBox('tx_impexp[filetype]', $inData['filetype'], $opt));
+        $this->standaloneView->assign('filetypeSelectOptions', $opt);
 
         $fileName = '';
         if ($saveFolder) {
@@ -954,40 +954,12 @@ class ImportExportController extends BaseScriptClass
     }
 
     /**
-     * Makes a selector-box from optValues
+     * Returns option array to be used in Fluid
      *
-     * @param string $prefix Form element name
-     * @param string $value Current value
-     * @param array $optValues Options to display (key/value pairs)
-     * @return string HTML select element
-     */
-    public function renderSelectBox($prefix, $value, $optValues)
-    {
-        $opt = array();
-        $isSelFlag = 0;
-        foreach ($optValues as $k => $v) {
-            $sel = (string)$k === (string)$value ? ' selected="selected"' : '';
-            if ($sel) {
-                $isSelFlag++;
-            }
-            $opt[] = '<option value="' . htmlspecialchars($k) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>';
-        }
-        if (!$isSelFlag && (string)$value !== '') {
-            $opt[] = '<option value="' . htmlspecialchars($value) . '" selected="selected">'
-                . htmlspecialchars(('[\'' . $value . '\']')) . '</option>';
-        }
-        return '<select name="' . $prefix . '">' . implode('', $opt) . '</select>';
-    }
-
-    /**
-     * Returns a selector-box with TCA tables
-     *
-     * @param string $prefix Form element name prefix
-     * @param array $value The current values selected
      * @param string $excludeList Table names (and the string "_ALL") to exclude. Comma list
-     * @return string HTML select element
+     * @return array
      */
-    public function tableSelector($prefix, $value, $excludeList = '')
+    public function getTableSelectOptions($excludeList = '')
     {
         $optValues = array();
         if (!GeneralUtility::inList($excludeList, '_ALL')) {
@@ -998,44 +970,7 @@ class ImportExportController extends BaseScriptClass
                 $optValues[$table] = $table;
             }
         }
-        // make box:
-        $opt = array();
-        $opt[] = '<option value=""></option>';
-        $sel = '';
-        foreach ($optValues as $k => $v) {
-            if (is_array($value)) {
-                $sel = in_array($k, $value) ? ' selected="selected"' : '';
-            }
-            $opt[] = '<option value="' . htmlspecialchars($k) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>';
-        }
-        return '<select name="' . $prefix . '[]" multiple="multiple" size="'
-            . MathUtility::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>';
-    }
-
-    /**
-     * Returns a selector-box with loaded extension keys
-     *
-     * @param string $prefix Form element name prefix
-     * @param array $value The current values selected
-     * @return string HTML select element
-     */
-    public function extensionSelector($prefix, $value)
-    {
-        $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
-
-        // make box:
-        $opt = array();
-        $opt[] = '<option value=""></option>';
-        foreach ($loadedExtensions as $extensionKey) {
-            $sel = '';
-            if (is_array($value)) {
-                $sel = in_array($extensionKey, $value) ? ' selected="selected"' : '';
-            }
-            $opt[] = '<option value="' . htmlspecialchars($extensionKey) . '"' . $sel . '>'
-                . htmlspecialchars($extensionKey) . '</option>';
-        }
-        return '<select name="' . $prefix . '[]" multiple="multiple" size="'
-            . MathUtility::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>';
+        return $optValues;
     }
 
     /**
index 3368c70..323f968 100644 (file)
@@ -40,7 +40,9 @@
                        <f:be.buttons.csh table="xMOD_tx_impexp" field="extensionDependencies" />
                </td>
                <td>
-                       <f:format.raw>{extensions}</f:format.raw>
+                       <f:form.select name="tx_impexp[extension_dep]" multiple="multiple"
+                                                                                size="{f:if(condition: '{extensions -> f:count()} > 9', then: '10', else: '5')}"
+                                                                                options="{extensions}" value="{inData.extension_dep}"/>
                </td>
        </tr>
        <tr class="bgColor4">
index 79bae44..6ddebd5 100644 (file)
@@ -27,7 +27,9 @@
                                <strong><f:translate key="makeconfig_levels" /></strong>
                                <f:be.buttons.csh table="xMOD_tx_impexp" field="pageTreeMode" />
                        </td>
-                       <td><f:format.raw>{levelSelect}</f:format.raw></td>
+                       <td>
+                               <f:form.select name="tx_impexp[pagetree][levels]" options="{levelSelectOptions}" value="{inData.pagetree.levels}" />
+                       </td>
                </tr>
                <tr class="bgColor4">
                        <td>
@@ -35,7 +37,9 @@
                                <f:be.buttons.csh table="xMOD_tx_impexp" field="pageTreeRecordLimit" />
                        </td>
                        <td>
-                               <f:format.raw>{tableSelect}</f:format.raw>
+                               <f:form.select name="tx_impexp[pagetree][tables]" options="{tableSelectOptions}"
+                                                                                        multiple="multiple" value="{inData.pagetree.tables}"
+                                                                                        size="{f:if(condition: '{tableSelectOptions -> f:count()} > 9', then: '10', else: '5')}" />
                                <br/>
                                <f:translate key="makeconfig_maxNumberOfRecords" />
                                <br/>
                        <strong><f:translate key="makeconfig_includeRelationsToTables" /></strong>
                        <f:be.buttons.csh table="xMOD_tx_impexp" field="inclRelations" />
                </td>
-               <td><f:format.raw>{externalReferenceTableSelect}</f:format.raw></td>
+               <td>
+                       <f:form.select name="tx_impexp[external_ref][tables]" options="{externalReferenceTableSelectOptions}"
+                                                                                multiple="multiple" value="{inData.external_ref.tables}"
+                                                                                size="{f:if(condition: '{externalReferenceTableSelectOptions -> f:count()} > 9', then: '10', else: '5')}" />
+               </td>
        </tr>
        <tr class="bgColor4">
                <td>
                        <strong><f:translate key="makeconfig_useStaticRelationsFor" /></strong>
                        <f:be.buttons.csh table="xMOD_tx_impexp" field="staticRelations" />
                </td>
-               <td><f:format.raw>{externalStaticTableSelect}</f:format.raw><br/>
+               <td>
+                       <f:form.select name="tx_impexp[external_static][tables]" options="{externalStaticTableSelectOptions}"
+                                                                                multiple="multiple" value="{inData.external_static.tables}"
+                                                                                size="{f:if(condition: '{externalStaticTableSelectOptions -> f:count()} > 9', then: '10', else: '5')}" />
+                       <br/>
                        <label for="checkShowStaticRelations">
                                <f:translate key="makeconfig_showStaticRelations" />
                        </label>
index 9af7759..2ee34f4 100644 (file)
@@ -9,7 +9,7 @@
                <td>
                        <f:translate key="makesavefo_selectPreset" />
                        <br/>
-                       <f:format.raw>{presetSelect}</f:format.raw>
+                       <f:form.select name="preset[select]" options="{presetSelectOptions}" />
 
                        <br/>
                        <input type="hidden" name="not-set" value="1" id="t3js-submit-field" />
@@ -59,7 +59,8 @@
                        <f:be.buttons.csh table="xMOD_tx_impexp" field="fileFormat" />
                </td>
                <td>
-                       <f:format.raw>{filetypeSelect}</f:format.raw><br/>
+                       <f:form.select name="tx_impexp[filetype]" options="{filetypeSelectOptions}" value="{inData.filetype}" />
+                       <br/>
                        <f:translate key="makesavefo_maxSizeOfFiles" /><br/>
                        <input type="text" name="tx_impexp[maxFileSize]" value="{inData.maxFileSize}" />
                        <br/>