[FEATURE] Replace usage of getFuncMenu with TWBS styled substitution 32/38032/19
authorJan Helke <typo3@helke.de>
Mon, 23 Mar 2015 10:53:49 +0000 (11:53 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 9 Jul 2015 21:18:45 +0000 (23:18 +0200)
This patch substitutes the inline usage of BackendUtility::getFuncMenu
with a Bootstrap styled variant.

Resolves: #65927
Releases: master
Change-Id: I2d5ec4097404a8a18cda6e4a205195230b81f53e
Reviewed-on: http://review.typo3.org/38032
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>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/frontend/Classes/Controller/PageInformationController.php
typo3/sysext/frontend/Classes/Controller/TranslationStatusController.php
typo3/sysext/info/Classes/Controller/InfoModuleController.php
typo3/sysext/info_pagetsconfig/Classes/Controller/InfoPageTyposcriptConfigController.php
typo3/sysext/lowlevel/Classes/View/DatabaseIntegrityView.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php

index 6e5072a..7473e8e 100644 (file)
@@ -2981,6 +2981,43 @@ class BackendUtility {
        }
 
        /**
+        * Returns a selector box to switch the view
+        * Requires the JS function jumpToUrl() to be available
+        * Based on BackendUtility::getFuncMenu() but done as new function because it has another purpose.
+        * Mingling with getFuncMenu would harm the docHeader Menu.
+        *
+        * @param mixed $mainParams The "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
+        * @param string $elementName The form elements name, probably something like "SET[...]
+        * @param string $currentValue The value to be selected currently.
+        * @param array $menuItems An array with the menu items for the selector box
+        * @param string $script The script to send the &id to, if empty it's automatically found
+        * @param string $addParams Additional parameters to pass to the script.
+        * @return string HTML code for selector box
+        */
+       static public function getDropdownMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addParams = '') {
+               if (!is_array($menuItems) || count($menuItems) <= 1) {
+                       return '';
+               }
+               $scriptUrl = self::buildScriptUrl($mainParams, $addParams, $script);
+               $options = array();
+               foreach ($menuItems as $value => $label) {
+                       $options[] = '<option value="' . htmlspecialchars($value) . '"' . ((string)$currentValue === (string)$value ? ' selected="selected"' : '') . '>' . htmlspecialchars($label, ENT_COMPAT, 'UTF-8', FALSE) . '</option>';
+               }
+               if (!empty($options)) {
+                       $onChange = 'jumpToUrl(' . GeneralUtility::quoteJSvalue($scriptUrl . '&' . $elementName . '=') . '+this.options[this.selectedIndex].value,this);';
+                       return '
+                       <div class="form-group">
+                               <!-- Function Menu of module -->
+                               <select class="form-control input-sm" name="' . htmlspecialchars($elementName) . '" onchange="' . htmlspecialchars($onChange) . '">
+                                       ' . implode(LF, $options) . '
+                               </select>
+                       </div>
+                                               ';
+               }
+               return '';
+       }
+
+       /**
         * Checkbox function menu.
         * Works like ->getFuncMenu() but takes no $menuItem array since this is a simple checkbox.
         *
index 3b11d03..04e561f 100644 (file)
@@ -28,7 +28,7 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
        /**
         * Returns the menu array
         *
-        * @return      array
+        * @return array
         */
        public function modMenu() {
                return array(
@@ -65,13 +65,21 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
                // PAGES:
                $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
                // ONLY for the sake of dblist module which uses this value.
-               $h_func = BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
-               $h_func .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
+               $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
+               $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
                $dblist->start($this->pObj->id, 'pages', 0);
                $dblist->generateList();
                // CSH
-               $theOutput = $this->pObj->doc->header($GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title'));
                $theOutput .= $this->pObj->doc->section('', BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', NULL, '|<br />') . $h_func . $dblist->HTMLcode, 0, 1);
+               $theOutput .= $this->pObj->doc->section(
+                       '',
+                       BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', NULL, '|<br />')
+                       . '<div class="form-inline form-inline-spaced">'
+                       . $h_func . $dblist->HTMLcode
+                       . '</div>',
+                       0,
+                       1
+               );
                // Additional footer content
                $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'];
                if (is_array($footerContentHook)) {
@@ -82,5 +90,4 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
                }
                return $theOutput;
        }
-
-}
+}
\ No newline at end of file
index 288b750..31b83f2 100644 (file)
@@ -62,11 +62,13 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
                $theOutput = $this->pObj->doc->header($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_title'));
                if ($this->pObj->id) {
                        // Depth selector:
-                       $h_func = BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
-                       $h_func .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
+                       $theOutput .= '<div class="form-inline form-inline-spaced">';
+                       $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
+                       $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
                        $theOutput .= $h_func;
                        // Add CSH:
                        $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', NULL, '|<br />');
+                       $theOutput .= '</div>';
                        // Showing the tree:
                        // Initialize starting point of page tree:
                        $treeStartingPoint = (int)$this->pObj->id;
index 37585ea..4ff3f9f 100644 (file)
@@ -105,7 +105,7 @@ class InfoModuleController extends BaseScriptClass {
                        // Setting up the context sensitive menu:
                        $this->doc->getContextMenuCode();
                        $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName)) .
-                               '" method="post" name="webinfoForm">';
+                               '" method="post" name="webinfoForm" class="form-inline form-inline-spaced">';
                        $vContent = $this->doc->getVersionSelector($this->id, 1);
                        if ($vContent) {
                                $this->content .= $this->doc->section('', $vContent);
index ddb3b09..abc2294 100644 (file)
@@ -91,8 +91,10 @@ class InfoPageTyposcriptConfigController extends \TYPO3\CMS\Backend\Module\Abstr
                                1
                        );
                } else {
-                       $menu = BackendUtility::getFuncMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
+                       $menu = '<div class="form-inline form-inline-spaced">';
+                       $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
                        $menu .= '<div class="checkbox"><label for="checkTsconf_alphaSort">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"') . $this->getLanguageService()->getLL('sort_alphabetic', TRUE) . '</label></div>';
+                       $menu .= '</div>';
                        $theOutput = $this->pObj->doc->header($this->getLanguageService()->getLL('tsconf_title'));
 
                        if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
index a3bea64..7c9df9a 100644 (file)
@@ -289,9 +289,13 @@ class DatabaseIntegrityView extends BaseScriptClass {
                $searchMode = $this->MOD_SETTINGS['search'];
                $fullsearch = GeneralUtility::makeInstance(QueryView::class);
                $fullsearch->setFormName($this->formName);
-               $submenu = BackendUtility::getFuncMenu(0, 'SET[search]', $searchMode, $this->MOD_MENU['search']);
+               $submenu = '<div class="form-inline form-inline-spaced">';
+               $submenu .= BackendUtility::getDropdownMenu(0, 'SET[search]', $searchMode, $this->MOD_MENU['search']);
+               if ($this->MOD_SETTINGS['search'] == 'query') {
+                       $submenu .= BackendUtility::getDropdownMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
+               }
+               $submenu .= '</div>';
                if ($this->MOD_SETTINGS['search'] == 'query') {
-                       $submenu .= BackendUtility::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
                        $submenu .= '<div class="checkbox"><label for="checkSearch_query_smallparts">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_query_smallparts]', $this->MOD_SETTINGS['search_query_smallparts'], '', '', 'id="checkSearch_query_smallparts"') . $lang->getLL('showSQL') . '</label></div>';
                        $submenu .= '<div class="checkbox"><label for="checkSearch_result_labels">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_result_labels]', $this->MOD_SETTINGS['search_result_labels'], '', '', 'id="checkSearch_result_labels"') . $lang->getLL('useFormattedStrings') . '</label></div>';
                        $submenu .= '<div class="checkbox"><label for="checkLabels_noprefix">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix'], '', '', 'id="checkLabels_noprefix"') . $lang->getLL('dontUseOrigValues') . '</label></div>';
index 50be5fa..f05c70c 100644 (file)
@@ -158,7 +158,9 @@ class TypoScriptTemplateConstantEditorModuleFunctionController extends AbstractF
                        }
                        $theOutput .= $this->pObj->doc->spacer(10);
                        if (!empty($this->pObj->MOD_MENU['constant_editor_cat'])) {
-                               $menu = BackendUtility::getFuncMenu($this->pObj->id, 'SET[constant_editor_cat]', $this->pObj->MOD_SETTINGS['constant_editor_cat'], $this->pObj->MOD_MENU['constant_editor_cat']);
+                               $menu = '<div class="form-inline form-inline-spaced">';
+                               $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[constant_editor_cat]', $this->pObj->MOD_SETTINGS['constant_editor_cat'], $this->pObj->MOD_MENU['constant_editor_cat']);
+                               $menu .= '</div>';
                                $theOutput .= $this->pObj->doc->section($lang->getLL('category', TRUE), '<span class="text-nowrap">' . $menu . '</span>', FALSE);
                        } else {
                                $theOutput .= $this->pObj->doc->section($lang->getLL('noConstants', TRUE), $lang->getLL('noConstantsDescription', TRUE), FALSE, FALSE, 1);
@@ -203,4 +205,4 @@ class TypoScriptTemplateConstantEditorModuleFunctionController extends AbstractF
                return $GLOBALS['theConstants'];
        }
 
-}
+}
\ No newline at end of file
index d11ea3e..8093210 100644 (file)
@@ -393,14 +393,14 @@ class TypoScriptTemplateObjectBrowserModuleFunctionController extends AbstractFu
                                $theOutput .= '
                                                <div class="form-group">
                                                        <label class="control-label">' . $lang->getLL('browse') . '</label>'
-                                                       . BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']). '
+                                                       . BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']). '
                                                </div>';
                        }
                        if(is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1){
                                $theOutput .= '
                                                <div class="form-group">
                                                        <label class="control-label" for="ts_browser_toplevel_' . $bType . '">' . $lang->getLL('objectList') . '</label> '
-                                                       . BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_toplevel_' . $bType . ']', $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) . '
+                                                       . BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_toplevel_' . $bType . ']', $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) . '
                                                </div>';
                        }
                        $theOutput .= '
@@ -474,8 +474,9 @@ class TypoScriptTemplateObjectBrowserModuleFunctionController extends AbstractFu
                        $menu .= '<div class="checkbox"><label for="checkTs_browser_fixedLgd">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'], '', '', 'id="checkTs_browser_fixedLgd"');
                        $menu .= $lang->getLL('cropLines') . '</label></div>';
                        if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
-                               $menu .= '<br /><br /><label>' . $lang->getLL('displayConstants') . '</label>';
-                               $menu .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
+                               $menu .= '<div class="form-inline form-inline-spaced"><label>' . $lang->getLL('displayConstants') . '</label>';
+                               $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
+                               $menu .= '</div>';
                        }
                        $menu .= '</div>';
                        $theOutput .= $this->pObj->doc->section($lang->getLL('displayOptions'), '<span class="text-nowrap">' . $menu . '</span>', 0, 1);