[TASK] Remove table usage in "User settings" + base on Twbs 93/33393/7
authorGeorg Ringer <georg.ringer@gmail.com>
Sun, 19 Oct 2014 18:45:30 +0000 (20:45 +0200)
committerBenjamin Mack <benni@typo3.org>
Sun, 26 Oct 2014 19:12:59 +0000 (20:12 +0100)
The module "User settings" currently uses tables to style the form.
This must be changed to use a proper markup.

Additionally fixed:
 * Typos
 * Strict comparison where nothing breaks for sure.

Resolves: #62328
Releases: master
Change-Id: I6af386b63cca6d2ca35eb169332f5e36f7d03542
Reviewed-on: http://review.typo3.org/33393
Reviewed-by: Felix Kopp <felix-source@phorax.com>
Tested-by: Felix Kopp <felix-source@phorax.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/openid/Classes/OpenidModuleSetup.php
typo3/sysext/setup/Classes/Controller/SetupModuleController.php
typo3/sysext/t3skin/Resources/Private/Styles/TYPO3/_main_form.less
typo3/sysext/t3skin/Resources/Public/Css/visual/t3kin.css

index 9906713..72055cf 100644 (file)
@@ -50,17 +50,21 @@ class OpenidModuleSetup {
                        $GLOBALS['LANG']->sL('LLL:EXT:openid/Resources/Private/Language/Wizard.xlf:addopenid')
                );
 
-               return '<input id="field_tx_openid_openid"' .
-                       $GLOBALS['TBE_TEMPLATE']->formWidth(20) .
+               return '<div class="input-group">' .
+                       '<input id="field_tx_openid_openid"' .
+                       ' class="form-control"' .
                        ' type="text" name="data[be_users][tx_openid_openid]"' .
                        ' value="' . htmlspecialchars($openid) . '" />' .
-                       '&nbsp;&nbsp;<a href="#" onclick="' .
-                       'vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_openid') . '&P[itemName]=data%5Bbe_users%5D%5Btx_openid_openid%5D') .
-                       ',null,\'width=600,height=400,status=0,menubar=0,scrollbars=0\');' .
-                       'vHWin.focus();return false;' .
-                       '">' .
-                       '<img src="../typo3/sysext/openid/ext_icon.gif" alt="' . $add . '" title="' . $add . '"/>' .
-                       '</a>';
+                       '<div class="input-group-addon">' .
+                               '<a href="#" onclick="' .
+                               'vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_openid') . '&P[itemName]=data%5Bbe_users%5D%5Btx_openid_openid%5D') .
+                               ',null,\'width=600,height=400,status=0,menubar=0,scrollbars=0\');' .
+                               'vHWin.focus();return false;' .
+                               '">' .
+                                       '<img src="../typo3/sysext/openid/ext_icon.gif" alt="' . $add . '" title="' . $add . '"/>' .
+                               '</a>' .
+                       '</div>' .
+                       '</div>';
        }
 
 }
index 83b13d8..6c8184d 100644 (file)
@@ -20,7 +20,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 /**
  * Module: User configuration
  *
- * This module lets users viev and change their individual settings
+ * This module lets users view and change their individual settings
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
@@ -160,7 +160,7 @@ class SetupModuleController {
                                                continue;
                                        }
                                        if ($config['table']) {
-                                               if ($config['table'] == 'be_users' && !in_array($field, array('password', 'password2', 'email', 'realName', 'admin'))) {
+                                               if ($config['table'] === 'be_users' && !in_array($field, array('password', 'password2', 'email', 'realName', 'admin'))) {
                                                        if (!isset($config['access']) || $this->checkAccess($config) && $GLOBALS['BE_USER']->user[$field] !== $d['be_users'][$field]) {
                                                                if ($config['type'] === 'check') {
                                                                        $fieldValue = isset($d['be_users'][$field]) ? 1 : 0;
@@ -172,7 +172,7 @@ class SetupModuleController {
                                                        }
                                                }
                                        }
-                                       if ($config['type'] == 'check') {
+                                       if ($config['type'] === 'check') {
                                                $GLOBALS['BE_USER']->uc[$field] = isset($d[$field]) ? 1 : 0;
                                        } else {
                                                $GLOBALS['BE_USER']->uc[$field] = htmlspecialchars($d[$field]);
@@ -269,14 +269,6 @@ class SetupModuleController {
                $this->doc->setModuleTemplate('EXT:setup/Resources/Private/Templates/setup.html');
                $this->doc->form = '<form action="' . BackendUtility::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded">';
                $this->doc->addStyleSheet('module', 'sysext/setup/Resources/Public/Styles/styles.css');
-               $this->doc->tableLayout = array(
-                       'defRow' => array(
-                               '0' => array('<td class="td-label">', '</td>'),
-                               'defCol' => array('<td valign="top">', '</td>')
-                       )
-               );
-               $this->doc->table_TR = '<tr>';
-               $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2" class="typo3-usersettings">';
                $this->doc->JScode .= $this->getJavaScript();
        }
 
@@ -297,7 +289,7 @@ class SetupModuleController {
        }
 
        /**
-        * Generate the main settings formular:
+        * Generate the main settings form:
         *
         * @return void
         */
@@ -359,7 +351,6 @@ class SetupModuleController {
 
                // Render the menu items
                $menuItems = $this->renderUserSetup();
-
                $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', FALSE, FALSE, 1, FALSE, 1, $this->dividers2tabs);
                $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
                $this->content .= $this->doc->section('', '<input type="hidden" name="simUser" value="' . $this->simUser . '" />
@@ -429,8 +420,8 @@ class SetupModuleController {
                $tabLabel = '';
                foreach ($fieldArray as $fieldName) {
                        $more = '';
-                       if (substr($fieldName, 0, 8) == '--div--;') {
-                               if ($firstTabLabel == '') {
+                       if (substr($fieldName, 0, 8) === '--div--;') {
+                               if ($firstTabLabel === '') {
                                        // First tab
                                        $tabLabel = $this->getLabel(substr($fieldName, 8), '', FALSE);
                                        $firstTabLabel = $tabLabel;
@@ -438,7 +429,7 @@ class SetupModuleController {
                                        if ($this->dividers2tabs) {
                                                $result[] = array(
                                                        'label' => $tabLabel,
-                                                       'content' => count($code) ? $this->doc->table($code) : ''
+                                                       'content' => count($code) ? implode(LF, $code) : ''
                                                );
                                                $tabLabel = $this->getLabel(substr($fieldName, 8), '', FALSE);
                                                $i = 0;
@@ -448,6 +439,7 @@ class SetupModuleController {
                                continue;
                        }
                        $config = $GLOBALS['TYPO3_USER_SETTINGS']['columns'][$fieldName];
+
                        // Field my be disabled in setup.fields
                        if (isset($this->tsFieldConf[$fieldName . '.']['disabled']) && $this->tsFieldConf[$fieldName . '.']['disabled'] == 1) {
                                continue;
@@ -458,8 +450,9 @@ class SetupModuleController {
                        $label = $this->getLabel($config['label'], $fieldName);
                        $label = $this->getCSH($config['csh'] ?: $fieldName, $label);
                        $type = $config['type'];
-                       $eval = $config['eval'];
                        $class = $config['class'];
+                       $class .= ' form-control';
+
                        $style = $config['style'];
                        if ($class) {
                                $more .= ' class="' . $class . '"';
@@ -470,75 +463,91 @@ class SetupModuleController {
                        if (isset($this->overrideConf[$fieldName])) {
                                $more .= ' disabled="disabled"';
                        }
-                       $value = $config['table'] == 'be_users' ? $GLOBALS['BE_USER']->user[$fieldName] : $GLOBALS['BE_USER']->uc[$fieldName];
+                       $value = $config['table'] === 'be_users' ? $GLOBALS['BE_USER']->user[$fieldName] : $GLOBALS['BE_USER']->uc[$fieldName];
                        if (!$value && isset($config['default'])) {
                                $value = $config['default'];
                        }
                        $dataAdd = '';
-                       if ($config['table'] == 'be_users') {
+                       if ($config['table'] === 'be_users') {
                                $dataAdd = '[be_users]';
                        }
+
                        switch ($type) {
-                       case 'text':
-                       case 'password':
-                               $noAutocomplete = '';
-                               if ($type === 'password') {
-                                       $value = '';
-                                       $noAutocomplete = 'autocomplete="off" ';
-                               }
-                               $html = '<input id="field_' . $fieldName . '"
-                                                       type="' . $type . '"
-                                                       name="data' . $dataAdd . '[' . $fieldName . ']" ' . $noAutocomplete . 'value="' . htmlspecialchars($value) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . $more . ' />';
-                               break;
-                       case 'check':
-                               if (!$class) {
-                                       $more .= ' class="check"';
+                               case 'text':
+                               case 'password': {
+                                       $noAutocomplete = '';
+                                       if ($type === 'password') {
+                                               $value = '';
+                                               $noAutocomplete = 'autocomplete="off" ';
+                                       }
+                                       $html = '<input id="field_' . $fieldName . '"
+                                               type="' . $type . '"
+                                               name="data' . $dataAdd . '[' . $fieldName . ']" ' .
+                                               $noAutocomplete .
+                                               'value="' . htmlspecialchars($value) . '" ' .
+                                               $more .
+                                               ' />';
+                                       break;
                                }
-                               $html = '<input id="field_' . $fieldName . '"
-                                                                       type="checkbox"
-                                                                       name="data' . $dataAdd . '[' . $fieldName . ']"' . ($value ? ' checked="checked"' : '') . $more . ' />';
-                               break;
-                       case 'select':
-                               if (!$class) {
-                                       $more .= ' class="select"';
+                               case 'check': {
+                                       $html = '<input id="field_' . $fieldName . '"
+                                               type="checkbox"
+                                               name="data' . $dataAdd . '[' . $fieldName . ']"' .
+                                               ($value ? ' checked="checked"' : '') .
+                                               $more .
+                                               ' />';
+                                       break;
                                }
-                               if ($config['itemsProcFunc']) {
-                                       $html = GeneralUtility::callUserFunction($config['itemsProcFunc'], $config, $this, '');
-                               } else {
-                                       $html = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_' . $fieldName . '" name="data' . $dataAdd . '[' . $fieldName . ']"' . $more . '>' . LF;
-                                       foreach ($config['items'] as $key => $optionLabel) {
-                                               $html .= '<option value="' . $key . '"' . ($value == $key ? ' selected="selected"' : '') . '>' . $this->getLabel($optionLabel, '', FALSE) . '</option>' . LF;
+                               case 'select': {
+                                       if ($config['itemsProcFunc']) {
+                                               $html = GeneralUtility::callUserFunction($config['itemsProcFunc'], $config, $this, '');
+                                       } else {
+                                               $html = '<select id="field_' . $fieldName . '"
+                                                       name="data' . $dataAdd . '[' . $fieldName . ']"' .
+                                                       $more . '>' . LF;
+                                               foreach ($config['items'] as $key => $optionLabel) {
+                                                       $html .= '<option value="' . $key . '"' . ($value == $key ? ' selected="selected"' : '') . '>' . $this->getLabel($optionLabel, '', FALSE) . '</option>' . LF;
+                                               }
+                                               $html .= '</select>';
                                        }
-                                       $html .= '</select>';
+                                       break;
                                }
-                               break;
-                       case 'user':
-                               $html = GeneralUtility::callUserFunction($config['userFunc'], $config, $this, '');
-                               break;
-                       case 'button':
-                               if ($config['onClick']) {
-                                       $onClick = $config['onClick'];
-                                       if ($config['onClickLabels']) {
-                                               foreach ($config['onClickLabels'] as $key => $labelclick) {
-                                                       $config['onClickLabels'][$key] = $this->getLabel($labelclick, '', FALSE);
+                               case 'user': {
+                                       $html = GeneralUtility::callUserFunction($config['userFunc'], $config, $this, '');
+                                       break;
+                               }
+                               case 'button': {
+                                       if ($config['onClick']) {
+                                               $onClick = $config['onClick'];
+                                               if ($config['onClickLabels']) {
+                                                       foreach ($config['onClickLabels'] as $key => $labelclick) {
+                                                               $config['onClickLabels'][$key] = $this->getLabel($labelclick, '', FALSE);
+                                                       }
+                                                       $onClick = vsprintf($onClick, $config['onClickLabels']);
                                                }
-                                               $onClick = vsprintf($onClick, $config['onClickLabels']);
+                                               $html = '<br><input type="button"
+                                                       value="' . $this->getLabel($config['buttonlabel'], '', FALSE) . '"
+                                                       onclick="' . $onClick . '" />';
                                        }
-                                       $html = '<input ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' type="button" value="' . $this->getLabel($config['buttonlabel'], '', FALSE) . '" onclick="' . $onClick . '" />';
+                                       break;
                                }
-                               break;
-                       default:
-                               $html = '';
+                               default:
+                                       $html = '';
                        }
-                       $code[$i][1] = $label;
-                       $code[$i++][2] = $html;
+
+                       $code[] = '<div class="form-group">' .
+                               $label .
+                               $html .
+                               '</div>';
                }
+
                if ($this->dividers2tabs == 0) {
                        $tabLabel = $firstTabLabel;
                }
+
                $result[] = array(
                        'label' => $tabLabel,
-                       'content' => count($code) ? $this->doc->table($code) : ''
+                       'content' => count($code) ? implode(LF, $code) : ''
                );
                return $result;
        }
@@ -588,7 +597,7 @@ class SetupModuleController {
                }
                ksort($languageOptions);
                $languageCode = '
-                               <select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_lang" name="data[lang]" class="select">' . implode('', $languageOptions) . '
+                               <select id="field_lang" name="data[lang]" class="form-control">' . implode('', $languageOptions) . '
                                </select>';
                if ($GLOBALS['BE_USER']->uc['lang'] && !@is_dir((PATH_typo3conf . 'l10n/' . $GLOBALS['BE_USER']->uc['lang']))) {
                        $languageUnavailableWarning = 'The selected language "' . $GLOBALS['LANG']->getLL(('lang_' . $GLOBALS['BE_USER']->uc['lang']), TRUE) . '" is not available before the language pack is installed.<br />' . ($GLOBALS['BE_USER']->isAdmin() ? 'You can use the Extension Manager to easily download and install new language packs.' : 'Please ask your system administrator to do this.');
@@ -619,7 +628,7 @@ class SetupModuleController {
                                }
                        }
                }
-               return '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . 'id="field_startModule" name="data[startModule]" class="select">' . $startModuleSelect . '</select>';
+               return '<select id="field_startModule" name="data[startModule]" class="form-control">' . $startModuleSelect . '</select>';
        }
 
        /**
@@ -645,7 +654,7 @@ class SetupModuleController {
                                }
                        }
                        if (count($opt)) {
-                               $this->simulateSelector = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_simulate" name="simulateUser" onchange="window.location.href=\'' . BackendUtility::getModuleUrl('user_setup') . '&simUser=\'+this.options[this.selectedIndex].value;"><option></option>' . implode('', $opt) . '</select>';
+                               $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'' . BackendUtility::getModuleUrl('user_setup') . '&simUser=\'+this.options[this.selectedIndex].value;"><option></option>' . implode('', $opt) . '</select>';
                        }
                }
                // This can only be set if the previous code was executed.
@@ -699,6 +708,8 @@ class SetupModuleController {
                } elseif ($access == 'admin') {
                        return $this->isAdmin;
                }
+
+               return FALSE;
        }
 
        /**
@@ -711,7 +722,7 @@ class SetupModuleController {
         * @return string HTML output.
         */
        protected function getLabel($str, $key = '', $addLabelTag = TRUE, $altLabelTagId = '') {
-               if (substr($str, 0, 4) == 'LLL:') {
+               if (substr($str, 0, 4) === 'LLL:') {
                        $out = $GLOBALS['LANG']->sL($str);
                } else {
                        $out = htmlspecialchars($str);
index 2658fd2..8489acd 100644 (file)
@@ -32,6 +32,11 @@ button {
 Form
 - - - - - - - - - - - - - - - - - - - - - */
 
+/* Limit form width globally */
+.form-group {
+       max-width: 440px;
+}
+
 input,
 textarea,
 button {
index 27339bd..9262089 100644 (file)
@@ -10101,6 +10101,10 @@ button {
 /* - - - - - - - - - - - - - - - - - - - - -
 Form
 - - - - - - - - - - - - - - - - - - - - - */
+/* Limit form width globally */
+.form-group {
+  max-width: 440px;
+}
 input,
 textarea,
 button {