[BUGFIX] Select correct module in User Settings 65/39465/4
authorMarkus Klein <markus.klein@typo3.org>
Mon, 11 May 2015 20:48:05 +0000 (22:48 +0200)
committerXavier Perseguers <xavier@typo3.org>
Wed, 13 May 2015 14:23:34 +0000 (16:23 +0200)
If the first entry of the select box is chosen (option has an
empty value), this selection is preserved now after saving the form.

Additionally the empty value given a proper label to describe its
functionality.

The rendering is adjusted to use optgroup-elements now.

Resolves: #66893
Releases: master
Change-Id: Ic6a77086a86d353075dc771a23df74617697f01e
Reviewed-on: http://review.typo3.org/39465
Reviewed-by: Frederic Gaus <frederic.gaus@flagbit.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
typo3/sysext/setup/Classes/Controller/SetupModuleController.php
typo3/sysext/setup/mod/locallang.xlf

index a5ee951..1048fa0 100644 (file)
@@ -668,19 +668,18 @@ class SetupModuleController {
         * @return string Complete select as HTML string
         */
        public function renderStartModuleSelect($params, $pObj) {
-               // Start module select
-               if (empty($this->getBackendUser()->uc['startModule'])) {
-                       $this->getBackendUser()->uc['startModule'] = $this->getBackendUser()->uc_default['startModule'];
-               }
-               $startModuleSelect = '<option value=""></option>';
+               $startModuleSelect = '<option value="">' . $this->getLanguageService()->getLL('startModule.firstInMenu', TRUE) . '</option>';
                foreach ($pObj->loadModules->modules as $mainMod => $modData) {
-                       if (isset($modData['sub']) && is_array($modData['sub'])) {
-                               $startModuleSelect .= '<option disabled="disabled">' . $this->getLanguageService()->moduleLabels['tabs'][($mainMod . '_tab')] . '</option>';
-                               foreach ($modData['sub'] as $subKey => $subData) {
+                       if (!empty($modData['sub']) && is_array($modData['sub'])) {
+                               $modules = '';
+                               foreach ($modData['sub'] as $subData) {
                                        $modName = $subData['name'];
-                                       $startModuleSelect .= '<option value="' . $modName . '"' . ($this->getBackendUser()->uc['startModule'] == $modName ? ' selected="selected"' : '') . '>';
-                                       $startModuleSelect .= ' - ' . $this->getLanguageService()->moduleLabels['tabs'][($modName . '_tab')] . '</option>';
+                                       $modules .= '<option value="' . htmlspecialchars($modName) . '"';
+                                       $modules .= $this->getBackendUser()->uc['startModule'] === $modName ? ' selected="selected"' : '';
+                                       $modules .=  '>' . $this->getLanguageService()->moduleLabels['tabs'][$modName . '_tab'] . '</option>';
                                }
+                               $groupLabel = $this->getLanguageService()->moduleLabels['tabs'][$mainMod . '_tab'];
+                               $startModuleSelect .= '<optgroup label="' . htmlspecialchars($groupLabel) . '">' . $modules . '</optgroup>';
                        }
                }
                return '<select id="field_startModule" name="data[startModule]" class="form-control">' . $startModuleSelect . '</select>';
index 8eba448..aec5726 100644 (file)
                        <trans-unit id="debugInWindow">
                                <source>Display debug messages in a new browser window</source>
                        </trans-unit>
+                       <trans-unit id="startModule.firstInMenu">
+                               <source>- First module in menu -</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>